diff options
author | Paolo Carlini <pcarlini@suse.de> | 2005-07-18 17:42:32 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2005-07-18 17:42:32 +0000 |
commit | 39a72a9179d83d97365c3c6417786e685bd95b5b (patch) | |
tree | d3138d3871b9a0e258c85e2c7513f5adcdaafdd2 | |
parent | eba839f9719e66195f75207b377593c025c71b82 (diff) | |
download | gcc-39a72a9179d83d97365c3c6417786e685bd95b5b.zip gcc-39a72a9179d83d97365c3c6417786e685bd95b5b.tar.gz gcc-39a72a9179d83d97365c3c6417786e685bd95b5b.tar.bz2 |
ctype_members.cc (do_is(mask, wchar_t)): Speed-up for the common case of mask == ctype_base::space...
2005-07-18 Paolo Carlini <pcarlini@suse.de>
* config/locale/gnu/ctype_members.cc (do_is(mask, wchar_t)):
Speed-up for the common case of mask == ctype_base::space;
otherwise, exit the loop earlier if the mask is one of the
elementary ones.
From-SVN: r102137
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/gnu/ctype_members.cc | 36 |
2 files changed, 32 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 15862e3..4f7b8db 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2005-07-18 Paolo Carlini <pcarlini@suse.de> + + * config/locale/gnu/ctype_members.cc (do_is(mask, wchar_t)): + Speed-up for the common case of mask == ctype_base::space; + otherwise, exit the loop earlier if the mask is one of the + elementary ones. + 2005-07-14 Paolo Carlini <pcarlini@suse.de> PR libstdc++/21193 (float, double, long double) diff --git a/libstdc++-v3/config/locale/gnu/ctype_members.cc b/libstdc++-v3/config/locale/gnu/ctype_members.cc index fcb0551..a006929 100644 --- a/libstdc++-v3/config/locale/gnu/ctype_members.cc +++ b/libstdc++-v3/config/locale/gnu/ctype_members.cc @@ -134,20 +134,34 @@ namespace std ctype<wchar_t>:: do_is(mask __m, wchar_t __c) const { - // Highest bitmask in ctype_base == 10, but extra in "C" - // library for blank. + // The case of __m == ctype_base::space is particularly important, + // due to its use in many istream functions. Therefore we deal with + // it first, exploiting the knowledge that on GNU systems _M_bit[5] + // is the mask corresponding to ctype_base::space. NB: an encoding + // change would not affect correctness! bool __ret = false; - const size_t __bitmasksize = 11; - for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) - if (__m & _M_bit[__bitcur] - && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype)) - { - __ret = true; - break; - } + if (__m == _M_bit[5]) + __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype); + else + { + // Highest bitmask in ctype_base == 10, but extra in "C" + // library for blank. + const size_t __bitmasksize = 11; + for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) + if (__m & _M_bit[__bitcur]) + { + if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype)) + { + __ret = true; + break; + } + else if (__m == _M_bit[__bitcur]) + break; + } + } return __ret; } - + const wchar_t* ctype<wchar_t>:: do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const |