diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-18 17:42:32 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-18 17:42:32 +0000 |
commit | e2392033a87eb56a953da81c198f7c870f80d908 (patch) | |
tree | d3138d3871b9a0e258c85e2c7513f5adcdaafdd2 /libstdc++-v3 | |
parent | 2806ee49f2b72c642ed1da9cbd1c53e4e0c08eb5 (diff) | |
download | gcc-e2392033a87eb56a953da81c198f7c870f80d908.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102137 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-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 15862e3772a..4f7b8db3831 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 fcb0551b382..a006929ac8e 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 |