[question] array of booleans or integer?(optimization)
In my plugin i made my own variable wich stores certain flags:
for example isAlive (int) and i do bitwise OR shifted bits (id) to set isAlive, id the compiler gives me a tag mismatch warning every time i use if(!getBit( isAlive, id )) so my question is shud i use an integer or bool:isAlive[33] to avoid the tag mismatch warnings. So my question is shud i use an integer or an array of booleans? |
Re: [question] array of booleans or integer?(optimization)
Use a single variable and leave it un-tagged. If you need further help post or pm your problem code.
|
Re: [question] array of booleans or integer?(optimization)
Here's a organized way of storing flags
You can have up to 32 flags. PHP Code:
|
Re: [question] array of booleans or integer?(optimization)
Well yeah i have macros too ^^
PHP Code:
|
Re: [question] array of booleans or integer?(optimization)
Quote:
|
Re: [question] array of booleans or integer?(optimization)
IMO, it would be easier to manage and code using what I posted above where each player their own bitfield of options versus having a variable of each flag and setting a player id bit to 1/0.
@fysiks, there was a discussion somewhere regarding the speed of id-1, id % 31, and id & 31, id & 31 turned out to be the most efficient. |
Re: [question] array of booleans or integer?(optimization)
So its faster? I only counted out the server itself. Im glad to hear.
Also i do know about assembly code and such i just dont look up each operator im using lol! |
Re: [question] array of booleans or integer?(optimization)
Quote:
|
Re: [question] array of booleans or integer?(optimization)
Well youre right in assembly commands it does make a HUGE difference. I did learn in college that % uses a division and some shifts and AND wil save you a lot of cpu with square numbers.
|
| All times are GMT -4. The time now is 10:24. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.