ID:153008
 
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 =$=
It shouldn't make any difference. The same amount of space is still used to store each value, and all bits are still operated on. The only difference would be if BYOND has to internally convert between numeric representations, but I don't think it does that.

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:
OPENSKY 1   // 2**0
CONFINED 2  // 2**1
DARK 4      // 2**2
FOREST 8    // 2**3
LAKE 16     // 2**4