If I have a list of 20 bit flags, should I assign the more often used ones to the lower values? Does this save resources any?
For example, say I am using bit flags to describe room properties, and these are some of the bitflags:
OPENSKY 1
CONFINED 16
DARK 128
FOREST 2048
LAKE 16384
Now, let's say that OPENSKY is a very often used property, nearly half the rooms have it, while the LAKE is very rare, less than 5% of the rooms use it. Is it smart to let LAKE be the highest integer value possible, while assigning OPENSKY to the lowest possible integer value? Or, does this not make any difference at all in Byond? I know this particular example only used 5 bit flags, but its easy to have a whole lot more than that, and integers can end up with very large values.
=$= Big J Money =$=
ID:153008
Apr 3 2005, 12:31 pm
|
|
So to answer your question, no, it has no measurable impact on resources.
By the way, you have several unused bits there. You can use powers of 2 for bitflags: