Skip to content

Improve performance by avoiding Glib::ustring

Max Gaukler requested to merge mgmax/inkscape:speedup-other-ustr into master

Using Glib::ustring with ==, <, .compare(), or as map key has unexpected consequences and performance hits: The checking uses g_utf8_collate(), which does locale-aware sorting and therefore takes much longer than std::string which uses something like strcmp().

This patch addresses several bottlenecks (as seen in Callgrind) by

  • converting Glib::ustring to std::string by applying .raw() before testing for equality

  • changing map key types to std::string

and therefore reduces the relative CPU usage of g_utf8_collate() from 4% to <1%. This should translate into ca. 0.2 seconds of startup time reduction out of currently 6 total seconds.

The timing measurement method and technical background are described here: !6311 (merged)

Please review closely, I'm not sure if this introduces pointer/memory related errors.

Related: !6311 (merged)

Merge request reports