String IDs

21 views
Skip to first unread message

iarwain

unread,
Oct 31, 2013, 12:06:29 AM10/31/13
to orx...@googlegroups.com
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

faistoiplaisir

unread,
Nov 1, 2013, 11:59:37 AM11/1/13
to orx...@googlegroups.com
Hey Rom!

Even If I not actif on Orx actually, I read posts here and some on the forum :)

This feature seems to be nice!

Just by curiosity, did you evaluate the gain of the optimization for the fast string comparaison in orx's internals module ?

This kind of post is really appreciated ! ;)

orx-project

unread,
Nov 5, 2013, 11:38:36 PM11/5/13
to orx...@googlegroups.com
Hehe, I'm glad to know you're still among us! :)

As for optimizations numbers, I don't have any sorry, it was mostly to
make the new object group feature lightweight.

On the memory side, it all depends on the size of your game. You can
check the profiler screen for text memory before and after that
optimization. :)

Cheers,

Rom


2013/11/1 faistoiplaisir <faistoi...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "orx-dev" group.
> To post to this group, send email to orx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/orx-dev.
Reply all
Reply to author
Forward
0 new messages