[Boost-bugs] [Boost C++ Libraries] #9318: Improve performance of boost string algorithms when converting case

Subject: [Boost-bugs] [Boost C++ Libraries] #9318: Improve performance of boost string algorithms when converting case
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-10-29 18:35:11


#9318: Improve performance of boost string algorithms when converting case
------------------------------+--------------------------
 Reporter: boost@… | Owner: marshall
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: string_algo
  Version: Boost 1.53.0 | Severity: Optimization
 Keywords: |
------------------------------+--------------------------
 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

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9318>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC