Opened 9 years ago

#9318 new Feature Requests

Improve performance of boost string algorithms when converting case

Reported by: boost@… Owned by: Marshall Clow
Milestone: To Be Determined Component: string_algo
Version: Boost 1.53.0 Severity: Optimization
Keywords: Cc:

Description

We recently switched STL library to libstdc++ and hit a performance snag on code that use boost string algorithms for converting case or comparing case insensitive.

I noticed that the algorithms use the standard C++ convenience functions for character classification for each and every character being converted or compared. This is very inefficient as these standard C++ functions in turn call std::use_facet every time they are called. At least in libstdc++, std::use_facet is very expensive as it involves quite a bit of code including a dynamic_cast.

To quote Josuttis' The C++ Standard Library: "It is much faster to obtain the corresponding facet from the locale and to use the functions on this object directly".

Indeed if I wrap boost::to_upper/lower (an other) with functions that cache and reuse the facet within the same call to to_upper/lower, I see a significant run time improvement. In fact my application can cache the facet for the entire duration of the program running, something the string algorithms cannot do since they must support on the fly locale changes, but I wonder if this latter case should be supported also?

Thanks for a great library.

Soren Soe

Change History (0)

Note: See TracTickets for help on using tickets.