View Single Post
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-22-2011 , 13:50   Re: Function checks vs variables
Reply With Quote #6

Please, do not use the expression of "'big' native" when talking about forwards. Even the size of the plugin can correlate a bit with the need of caching, this is a barely acceptable advise. In general it is better for performance to cache values assuming that the native for checking the value is called more often than the forward changing the value. Somehow caching is not always necessary as it is more writing but still a good habit when using for example already mentioned per frame called forwards.

Quote:
Originally Posted by Bugsy View Post
I usually do not cache is alive or is connected since these change often and are inexpensive on the CPU to call.
A player does not die or connect often, in fact these are one of the most infrequently happening events on the whole server. Everything happens more ( some equally ) often expect a couple of exceptions like a map change.

Quote:
Originally Posted by Bugsy View Post
For caching bools it's best to use bit fields for efficiency.
You are not talking about memory only but also CPU and you are wrong. The defines you use for bit fields are slower for checking a single value than using an array. It is faster only in the rare case of checking if any of the values is true or that if all are false.
SnoW is offline
Send a message via MSN to SnoW