Commit c9a5bd54 by Paolo Carlini Committed by Paolo Carlini

PR libstdc++/28277 (partial: money_put bits)

2006-10-09  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/28277 (partial: money_put bits)
	* include/bits/locale_facets.tcc (money_put<>::_M_insert(iter_type,
	ios_base&, char_type, const string_type&)): Avoid __builtin_alloca
	with no limit, do the work in place.

	* include/bits/locale_facets.tcc (money_put<>::do_put(iter_type,
	bool, ios_base&, char_type, long double)): Avoid unnecessary
	__builtin_alloca, do the work in place.

From-SVN: r117571
parent a145e9b6
2006-10-09 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: money_put bits)
* include/bits/locale_facets.tcc (money_put<>::_M_insert(iter_type,
ios_base&, char_type, const string_type&)): Avoid __builtin_alloca
with no limit, do the work in place.
* include/bits/locale_facets.tcc (money_put<>::do_put(iter_type,
bool, ios_base&, char_type, long double)): Avoid unnecessary
__builtin_alloca, do the work in place.
2006-10-09 Benjamin Kosnik <bkoz@redhat.com> 2006-10-09 Benjamin Kosnik <bkoz@redhat.com>
* src/globals_io.cc (_GLIBCXX_once): Remove, unused. * src/globals_io.cc (_GLIBCXX_once): Remove, unused.
......
...@@ -1640,22 +1640,20 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE ...@@ -1640,22 +1640,20 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
// Add thousands separators to non-decimal digits, per // Add thousands separators to non-decimal digits, per
// grouping rules. // grouping rules.
int __paddec = __len - __lc->_M_frac_digits; long __paddec = __len - __lc->_M_frac_digits;
if (__paddec > 0) if (__paddec > 0)
{ {
if (__lc->_M_frac_digits < 0) if (__lc->_M_frac_digits < 0)
__paddec = __len; __paddec = __len;
if (__lc->_M_grouping_size) if (__lc->_M_grouping_size)
{ {
_CharT* __ws = __value.assign(2 * __paddec, char_type());
static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) _CharT* __vend =
* 2 * __len)); std::__add_grouping(&__value[0], __lc->_M_thousands_sep,
_CharT* __ws_end =
std::__add_grouping(__ws, __lc->_M_thousands_sep,
__lc->_M_grouping, __lc->_M_grouping,
__lc->_M_grouping_size, __lc->_M_grouping_size,
__beg, __beg + __paddec); __beg, __beg + __paddec);
__value.assign(__ws, __ws_end - __ws); __value.erase(__vend - &__value[0]);
} }
else else
__value.assign(__beg, __paddec); __value.assign(__beg, __paddec);
...@@ -1755,9 +1753,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE ...@@ -1755,9 +1753,7 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
money_put<_CharT, _OutIter>:: money_put<_CharT, _OutIter>::
__do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill, __do_put(iter_type __s, bool __intl, ios_base& __io, char_type __fill,
double __units) const double __units) const
{ { return this->do_put(__s, __intl, __io, __fill, (long double) __units); }
return this->do_put(__s, __intl, __io, __fill, (long double) __units);
}
#endif #endif
template<typename _CharT, typename _OutIter> template<typename _CharT, typename _OutIter>
...@@ -1791,10 +1787,8 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE ...@@ -1791,10 +1787,8 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf", int __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, "%.*Lf",
0, __units); 0, __units);
#endif #endif
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) string_type __digits(__len, char_type());
* __cs_size)); __ctype.widen(__cs, __cs + __len, &__digits[0]);
__ctype.widen(__cs, __cs + __len, __ws);
const string_type __digits(__ws, __len);
return __intl ? _M_insert<true>(__s, __io, __fill, __digits) return __intl ? _M_insert<true>(__s, __io, __fill, __digits)
: _M_insert<false>(__s, __io, __fill, __digits); : _M_insert<false>(__s, __io, __fill, __digits);
} }
......
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