Comments (6)
Relevant benchmark:
Lines 38 to 49 in 0cc76c1
from vnodes.
I actually didn't benchmark my maps, I mostly just used the unordered_map
from Boost up until a few-odd years ago when https://github.com/greg7mdp/sparsepp came out. I only do path lookups rarely, mostly at 'loading' time (like level load or so) and just cached the result where needed in the systems. For dynamic access I'd often use more direct calls as they know what they are accessing anyway so could refine the type to be specific. Mostly at 'play time' the paths would be accessed for debugging information, but otherwise it was almost entirely cached.
Do note, the (hash/tree)maps I generally only used on branching nodes, most specific nodes were a unique type that held it's own information much more specific for it's purpose, like if they were an entity link or a piece of hardware or so.
So honestly I'd not worry too much about performance, it's good to improve it, but it's primarily accessed not at play-time itself so it was never an issue for me.
from vnodes.
I'm pretty sure there will be cases where I don't know the type of the node, but I can cache them, yes.
from vnodes.
Yeah, in my systems I'd often have them be like (not at home so from memory):
struct some_system {
private:
SomeNode *nodeblah_;
AnotherNode *nodebloop_;
Node *unknownnode_;
public:
some_system(Context &ctx) {
nodeblah_ = ctx.rootnode<SomeNode>["/dev/some"]; // These are type safe, null pointer if not the right type
nodebloop_ = ctx.rootnode<AnotherNode>["/vwoop"]["/vweep"];
unknownnode_ = ctx.rootnode["/some/node/that/I/don't/know/the/type/of"];
assert(nodeblah_);
assert(nodebloop_);
assert(unknownnode_);
}
void operator()() {
// process system, maybe access `nodeblah_` straight, maybe access a
// child of nodebloop_, maybe set event hooks on unknownnode_, whatever...
}
// ... other things It was templated so only relevant parts were accessed
// efficiently without pointer indirections needed as well as being able to
// generate 'most' of the dependency graph at compile-time and generated the
// rest at load-time.
}
from vnodes.
from vnodes.
The problem I see with hardcoding the type is that the node cannot be
easily overwritten, which could be quite useful for modding.
Hmm, I've never actually needed to script-up a node that wasn't an entity so I've never seen the need. Most of my 'nodes' are just entity link's (EntityNode), which you then pass to systems as normal. Systems, on the other hand, have been heavily scripted and modded (as well as components). Scripts/mods can, however, 'access' Nodes with no issues, including via their fully dynamic interfaces.
from vnodes.
Related Issues (5)
- Design HOT 2
- Borrowing model HOT 20
- Passing multiple args to a function HOT 1
- Write blog post HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vnodes.