- Fairy Tale Twist
It’s always interesting putting a code-base you’re familiar with to a new platform, typically involving a new compiler (new and different errors, warnings and libraries) and exercises the code in different places. In this instance, running under the browser we’re hitting memory hard. Interestingly _strlen is in the top 30 in a profile trace, and drilling into call stacks our string handling and parsing feature in inner loops.
- switching events from using std::string to char , all of the defines for types of events are static and const char, which were then promoted to temporary std::strings. Removing this dropped events from the callstack.
- switching our xml accessors from returning std::string to char, natively libxml returns xmlChar which can be aliased to char*, avoiding another std::string promotion.
- switching from parse<int> and parse<float> to, old school, atoi and atof, again avoiding temporary promotion to std::string And there is more scope for switching away from strings to char* and from strings to int (there are a few places where numbers are passed as strings). After two days of optimizing load times when from 30-60secs to 11seconds.