Search code examples
c++stringidentifierogre3d

Using strings to identify objects: what's the purpose?


OGRE3D for example uses strings to identify objects, so each time the code does something on an object using its name (a string), it has to do string operations, and since a 3D engine is very sensitive on speed, how can it be a good way on doing it ?

When a computer has to do operations on a string, it does it sequentially, bytes after bytes, so it spend more CPU cycles if the string is longer...

Wouldn't it be faster to use plain variable names in code instead of using string identifiers ?


Solution

  • Well I got the answer by a teacher:

    In fact a string identifier, once in a map thus inserted in order, is quickly found with a dichotomic search.