Hey all,
First of all, sorry for being late to introduce some of the latest features.
So, what are String IDs? Well, they're actually pretty simple, they're just a huge dictionary containing strings using their CRCs as keys.
The main advantages being:
- Each string is uniquely stored once and only once. If you call orxString_GetID(zSomeString), you'll get its CRC as a result and you know that the content of zSomeString will be uniquely stored within the internal dictionary. That means you don't need to copy that string yourself for storage => no more duplication.
- No need to store the string itself in your own structure. You can simply store its key (a 32bit CRC) and use this value for quick comparison (instead of orxString_Compare). You can also find the content of the string as anytime by calling orxString_GetFromID(u32StringCRC).
Alternatively to storing the CRC locally, one can also store the const orxSTRING returned by orxString_GetFromID(). This pointer will not change and will be valid for this execution of orx, so you can even do an arithmetic comparison using that pointer if you feel like it.
If you want to have a string stored by orx using this system and keep a pointer to the permanent result, simply call:
const orxSTRING zMyPermanentString = orxString_GetFromID(orxString_GetID(zMyInitialString));
You can be sure zMyPermanentString will always be valid and contain the string you expect. You are not responsible for any cleaning either.
Most strings in internal components (config, commands, etc...) that were previously duplicated are now using this system allowing for fast comparisons and efficient memory storage.
Some new systems, such as object groups (cf. next post) are actually only dealing with the CRCs themselves.
Lemme know if you have any questions.
Cheers,
Rom