Some people have different levels of donator, sooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooo..
|
Why use for ints for example, "isDonator". Cause most servers just use isDonator == 1,
When you can use a boolean? Which is faster to load?
meaning if(isDonator) or if(!isDonator) compared to if(isDonator == 1) && if(isDonator == 0).
I cant seem to find any information on the web about this.
Reprogramming my player saving to be as efficient as possible.
Some people have different levels of donator, sooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooo..
You'll feel absolutely no difference when changing that.
I'm even unsure if it'd technically really be a difference. A boolean could be interpreted
as integer for faster calculating operations...
Boolean evaluating is probably faster (by like what, tiny fraction of a nano?) than evaluating an integer value, but you're basically picking for specks of dust on the body of a dying man if you're really serious about doing that for performance lmfao
There would be no difference in speed, however memory would be a very small difference from 4 bytes to just the 1.
You could also use a short which is just 2 bytes, if you are really into that sort of thing. Would most likely find yourself casting to an integer later though anyway... The only real time you would worry about this is when using 1000's of objects, for example the player object, hence why servers are finally converting constants etc rather then spawning new ones per player object spawned.
player saving is efficient as fuck, player loading isnt
afaik
The Sun JVM internally implements booleans as bytes.
Also, on the stack, bytes and shorts occupy 4 bytes (rather than 1 and 2 respectively). I think they may even occupy that amount as class variables too, due to the alignment, although I'm not 100% sure. It'll only start saving you space when you use them as arrays.
Of course, there are other reasons to use these types than efficiency. If the donator status should only be yes or no, then you should use a boolean even though it is going to end up having no difference on performance, as it makes the code cleared and you don't have to worry about it possibly being set to other values like 2, 3, 4, etc.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |