Boost C++ Libraries: Ticket #9318: Improve performance of boost string algorithms when converting case https://svn.boost.org/trac10/ticket/9318 <p> 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. </p> <p> 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. </p> <p> 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". </p> <p> 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? </p> <p> Thanks for a great library. </p> <p> Soren Soe </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9318 Trac 1.4.3