compareIgnoreCase speed


#1

Trying to track down a problem, I did an analysis of my app under Shark, and found that a disproportionate amount of my time was spent in CharacterFunctions::compareIgnoreCase(wchar_t const*, wchar_t const*). This isn’t something I’m calling directly, but is apparently called extensively by the PropertiesFile constructor.

In looking at the routine, it walks the whole string, and changes each character in turn toUpperCase(), so I can imagine that gets expensive as it’s called on each property in my PropertyFile.

Is there a way to make this more efficient?


#2

The routine is only slow if you’re comparing two strings which are the same, but which are all in different cases.

If the strings are different, or identical, or even mostly identical with just a few letters of different case, it’ll be pretty much as fast as a normal comparison… I can’t see any obvious way of improving it!