Thanks everyone for the input.
In answer to the statement about ‘try it yourself’; whilst I appreciate the sentiment here (since there are plenty of people on these forums looking for ‘quick answers’ with minimal research), I already have a large program that would take some re-engineering to apply some of the proposed principles. Naturally, knocking up a simple program to measure the efficiency gains on restructuring these arrays wouldn’t be accurate, since it wouldn’t take into account all of the other program activity that’s taking place at the same time as well (i.e. it’d be difficult to measure performance with everything else going on).
I understand where you’re coming from, though, but on this occasion some peer-Q&A would be more beneficial to prevent me making time-costly mistakes in this program’s development than simply experimenting.
In relation to another comment posted above about using the EnumType.values() statement to evaluate the required ordinal at runtime - I had no idea this returned a whole new array. I assumed that the EnumType was generated into an array-style accessor at compile time. I’m assuming that the way around this, as you suggested, would be to set up something like this (a one-time deal):
TileFlag[] flagValues = TileFlag.values();
TileFlag[] flagDefs = new TileFlag[flagValues.length];
for (int i = 0; i < flagValues.length; i++)
{
flagDefs[i] = flagValues [i];
}
So flagDefs is now my main ‘cached’ enum reference array, rather than using TileFlag.values()[…] (if I make flagDefs static, as well).?
Apologies if the code is sloppy, been a long day today!
Thanks!