« MBS Xojo / Real Studi… | Home | MBS Xojo / Real Studi… »

Faster String handling

We have a central C++ class in our Xojo plugins to access string content. Recently I discovered that one of the apps here is really slow working on strings with plugin functions. And I discovered most time is spend on text converting.

The string passed to plugin has some encoding and internally we need some encoding to do what we need to do, e.g. a function needs UTF16, but the Xojo string is UTF-8 or Windows ANSI or whatever. So we use ConvertString to convert the encoding. In the plugins we actually call REALGetStringData function from the plugin-sdk.

But most strings are in UTF-8 in Xojo and in fact most times also just ASCII strings. So we can optimize this.
So for converting from ASCII string to Windows ANSI, MacRoman and UTF-8, we don't need to convert at all.
For ASCII string to UTF32 or UTF16 we can omit the convert and just do it ourselves. This saves a lot of time in our tests here.

So by not using the Text Converter here we can save over 90% of the CPU time to get the content of a string in a given encoding.
Of course not for all strings, but for most. Please try in 16.3pr3 soon.
18 06 16 - 19:34