Frequently Asked Questions > Writing Better and Faster Scripts > How To Make It Faster? >

# Use bitArrays instead of Arrays when possible

MAXScript FAQ > How To Make It Faster > Use bitArrays instead of Arrays when possible

Many mesh-related methods operate on bitArrays. A bitArray stores only true and false flags and is very memory-efficient, but on the other hand, appending new elements to a bitArray is much slower than appending new elements to a regular array.

If the bitArray is of fixed size (for example returned by another method), using a bitArray is better than using a regular array.

If the final size of the array or bitArray is known, you can predeclare the array to reserve memory for as many elements by assigning a value to the last element as described below. Setting the values of arrays of bitArrays using indexed access to their elements after that is very fast. In this case, if you can need only true and false values, use a bitArray.

BitArray Values

Array Values

Previous Tip

Dice your data into smaller pieces

Next Tip

Pre-initialize arrays when final size is known