mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-30 07:14:09 +08:00
locale_facets.tcc (time_get::do_get_year): Avoid using a basic_string and calling a full blown strtol (via __convert_to_v)...
2003-12-02 Paolo Carlini <pcarlini@suse.de> * include/bits/locale_facets.tcc (time_get::do_get_year): Avoid using a basic_string and calling a full blown strtol (via __convert_to_v) for simple 2 or 4 digits, base 10, positive integers; simplify. From-SVN: r74193
This commit is contained in:
parent
0548bb4aba
commit
17e15f7f3b
@ -1,3 +1,10 @@
|
||||
2003-12-02 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/locale_facets.tcc (time_get::do_get_year):
|
||||
Avoid using a basic_string and calling a full blown strtol
|
||||
(via __convert_to_v) for simple 2 or 4 digits, base 10,
|
||||
positive integers; simplify.
|
||||
|
||||
2003-12-02 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* config/locale/gnu/monetary_members.cc
|
||||
|
@ -1964,21 +1964,17 @@ namespace std
|
||||
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
|
||||
|
||||
size_t __i = 0;
|
||||
string __digits;
|
||||
for (; __i < 4 && __beg != __end
|
||||
&& __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
|
||||
__digits += __ctype.narrow(*__beg, 0);
|
||||
if (__i == 2 || __i == 4)
|
||||
int __value = 0;
|
||||
for (; __beg != __end && __i < 4; ++__beg, ++__i)
|
||||
{
|
||||
long __l;
|
||||
std::__convert_to_v(__digits.c_str(), __l, __err,
|
||||
_S_get_c_locale());
|
||||
if (!(__err & ios_base::failbit) && __l <= INT_MAX)
|
||||
{
|
||||
__l = __i == 2 ? __l : __l - 1900;
|
||||
__tm->tm_year = static_cast<int>(__l);
|
||||
}
|
||||
const char __c = __ctype.narrow(*__beg, '*');
|
||||
if (__c >= '0' && __c <= '9')
|
||||
__value = __value * 10 + (__c - '0');
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (__i == 2 || __i == 4)
|
||||
__tm->tm_year = __i == 2 ? __value : __value - 1900;
|
||||
else
|
||||
__err |= ios_base::failbit;
|
||||
if (__beg == __end)
|
||||
|
Loading…
Reference in New Issue
Block a user