From: Paolo Carlini Date: Wed, 2 Feb 2005 16:46:40 +0000 (+0000) Subject: re PR libstdc++/19642 (streaming doubles is very slow compared to sprintf) X-Git-Tag: releases/gcc-3.4.4~251 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66c8838fc2d84dc96aff016c579ff8e8cb5f3318;p=thirdparty%2Fgcc.git re PR libstdc++/19642 (streaming doubles is very slow compared to sprintf) 2005-02-02 Paolo Carlini PR libstdc++/19642 * config/locale/generic/c_locale.h (__convert_from_v): Switch only LC_NUMERIC, and only when actually != "C". From-SVN: r94593 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d2d64ad736cf..76890751654d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2005-02-02 Paolo Carlini + + PR libstdc++/19642 + * config/locale/generic/c_locale.h (__convert_from_v): Switch only + LC_NUMERIC, and only when actually != "C". + 2005-01-31 Brad Spencer * crossconfig.m4: Repair Solaris cross bits for strtold and strtof. diff --git a/libstdc++-v3/config/locale/generic/c_locale.h b/libstdc++-v3/config/locale/generic/c_locale.h index a1a568686136..7b2282b04f65 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.h +++ b/libstdc++-v3/config/locale/generic/c_locale.h @@ -59,18 +59,26 @@ namespace std const char* __fmt, _Tv __v, const __c_locale&, int __prec) { - char* __old = std::setlocale(LC_ALL, NULL); - char* __sav = new char[std::strlen(__old) + 1]; - std::strcpy(__sav, __old); - std::setlocale(LC_ALL, "C"); + char* __old = std::setlocale(LC_NUMERIC, NULL); + char* __sav = NULL; + if (std::strcmp(__old, "C")) + { + __sav = new char[std::strlen(__old) + 1]; + std::strcpy(__sav, __old); + std::setlocale(LC_NUMERIC, "C"); + } #ifdef _GLIBCXX_USE_C99 const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v); #else const int __ret = std::sprintf(__out, __fmt, __prec, __v); #endif - std::setlocale(LC_ALL, __sav); - delete [] __sav; + + if (__sav) + { + std::setlocale(LC_NUMERIC, __sav); + delete [] __sav; + } return __ret; } }