How about just using the ACTUAL CASE, instead of making a lot of confusing and stupid analogies?
The CVAR structure is an enormous linked list, meaning that every time you use the normal syntax for getting CVAR's, you have the potential to force the server to check every single CVAR. This is O(N) performance, or linear, and is absolutely terrible.
The server itself registers lots of CVAR's, other plugins register CVAR's, and your plugin registers CVAR's. This means that your one little call to find a CVAR's value could very well be hundreds of string comparisons and indirections (and usually is).
However, if you use the pointer syntax, you reduce this huge overhead to a single indirection, O(1) performance, which is the best performance possible, and worlds better than the other syntax.
You waste 1 cell of memory, 4 bytes, in order to reduce an operation which is potentially hundreds of string comparisons, hundreds of indirections, and millions of cycles, to a single indirection, perhaps a hundred cycles, less if it is in cache.
Save a million cycles, waste 4 bytes, make your code a little more complex.
This isn't about a memory / speed tradeoff. Trade off implies that there is some benefit either way over the other. There is absolutely no benefit to saving 4 bytes today, even on the smallest of microprocessors, if it means wasting potentially millions of cycles.
__________________
.png" rel="nofollow noopener">
Last edited by Twilight Suzuka; 11-07-2007 at 03:54.
|