Commit 17e15f7f by Paolo Carlini Committed by Paolo Carlini

locale_facets.tcc (time_get::do_get_year): Avoid using a basic_string and…

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
parent 0548bb4a
2003-12-02 Paolo Carlini <pcarlini@suse.de> 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 * config/locale/gnu/monetary_members.cc
(money_base::_S_construct_pattern): For case 3: and 4: (money_base::_S_construct_pattern): For case 3: and 4:
exchanging 'if (__precedes)' and 'if (__space)' allows exchanging 'if (__precedes)' and 'if (__space)' allows
......
...@@ -1964,21 +1964,17 @@ namespace std ...@@ -1964,21 +1964,17 @@ namespace std
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
size_t __i = 0; size_t __i = 0;
string __digits; int __value = 0;
for (; __i < 4 && __beg != __end for (; __beg != __end && __i < 4; ++__beg, ++__i)
&& __ctype.is(ctype_base::digit, *__beg); ++__beg, ++__i)
__digits += __ctype.narrow(*__beg, 0);
if (__i == 2 || __i == 4)
{ {
long __l; const char __c = __ctype.narrow(*__beg, '*');
std::__convert_to_v(__digits.c_str(), __l, __err, if (__c >= '0' && __c <= '9')
_S_get_c_locale()); __value = __value * 10 + (__c - '0');
if (!(__err & ios_base::failbit) && __l <= INT_MAX) else
{ break;
__l = __i == 2 ? __l : __l - 1900;
__tm->tm_year = static_cast<int>(__l);
}
} }
if (__i == 2 || __i == 4)
__tm->tm_year = __i == 2 ? __value : __value - 1900;
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
if (__beg == __end) if (__beg == __end)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment