Author: faridz Date: Wed Dec 19 06:28:28 2007 New Revision: 605550 URL: http://svn.apache.org/viewvc?rev=605550&view=rev Log: 2007-12-19 Farid Zaripov <[EMAIL PROTECTED]>
Merged r605548 from branches/4.2.x with a fix for STDCXX-226 * include/rw/_defs.h (_RWSTD_RATIO_DIVIDER): New macro defined the value to divide the _RWSTD_{NEW|STRING}_CAPACITY_RATIO. (_RWSTD_NEW_CAPACITY_RATIO): The value with floating point replaced to integer value using multiplication with _RWSTD_RATIO_DIVIDER. (_RWSTD_STRING_CAPACITY_RATIO): Ditto. * include/rw/_specialized.h (__rw_new_capacity): Floating point operations replaced to integer operations. * include/sstream (_C_grow): Ditto. * include/string (__rw_new_capacity): Ditto. Modified: incubator/stdcxx/trunk/include/rw/_defs.h incubator/stdcxx/trunk/include/rw/_specialized.h incubator/stdcxx/trunk/include/sstream incubator/stdcxx/trunk/include/string Modified: incubator/stdcxx/trunk/include/rw/_defs.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/rw/_defs.h?rev=605550&r1=605549&r2=605550&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/rw/_defs.h (original) +++ incubator/stdcxx/trunk/include/rw/_defs.h Wed Dec 19 06:28:28 2007 @@ -431,19 +431,26 @@ // function overloads in the string header. These are tweakable here // with the STRING version of these macros. // +#if !defined (_RWSTD_RATIO_DIVIDER) +# define _RWSTD_RATIO_DIVIDER 1000U +#endif + #if !defined(_RWSTD_MINIMUM_NEW_CAPACITY) # define _RWSTD_MINIMUM_NEW_CAPACITY 32U #endif + #if !defined(_RWSTD_NEW_CAPACITY_RATIO) // using long doubles to eliminate bogus warnings on g++ 2.95.2/sparc // (-W -O2/3 only): warning: overflow on truncation to integer -# define _RWSTD_NEW_CAPACITY_RATIO 1.618L +# define _RWSTD_NEW_CAPACITY_RATIO 1618U #endif + #if !defined(_RWSTD_MINIMUM_STRING_CAPACITY) # define _RWSTD_MINIMUM_STRING_CAPACITY 128U #endif + #if !defined(_RWSTD_STRING_CAPACITY_RATIO) -# define _RWSTD_STRING_CAPACITY_RATIO 1.618L +# define _RWSTD_STRING_CAPACITY_RATIO 1618U #endif #if !defined (_RWSTD_MINIMUM_STRINGBUF_CAPACITY) Modified: incubator/stdcxx/trunk/include/rw/_specialized.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/rw/_specialized.h?rev=605550&r1=605549&r2=605550&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/rw/_specialized.h (original) +++ incubator/stdcxx/trunk/include/rw/_specialized.h Wed Dec 19 06:28:28 2007 @@ -69,8 +69,12 @@ { typedef _RWSTD_CONTAINER_SIZE_TYPE _RWSizeT; - _RWSizeT __cap = _RWSTD_STATIC_CAST (_RWSizeT, - __size * _RWSTD_NEW_CAPACITY_RATIO); + const _RWSizeT __ratio = _RWSizeT ( (_RWSTD_NEW_CAPACITY_RATIO << 10) + / _RWSTD_RATIO_DIVIDER); + + const _RWSizeT __cap = (__size >> 10) * __ratio + + (((__size & 0x3ff) * __ratio) >> 10); + return (__size += _RWSTD_MINIMUM_NEW_CAPACITY) > __cap ? __size : __cap; } Modified: incubator/stdcxx/trunk/include/sstream URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/sstream?rev=605550&r1=605549&r2=605550&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/sstream (original) +++ incubator/stdcxx/trunk/include/sstream Wed Dec 19 06:28:28 2007 @@ -207,11 +207,15 @@ basic_stringbuf<_CharT, _Traits, _Allocator>:: _C_grow (_RWSTD_STREAMSIZE __to) const { + const _RWSTD_STREAMSIZE __ratio = + _RWSTD_STREAMSIZE ( (_RWSTD_NEW_CAPACITY_RATIO << 10) + / _RWSTD_RATIO_DIVIDER); + const _RWSTD_STREAMSIZE __cap = - _RWSTD_STATIC_CAST (_RWSTD_STREAMSIZE, - this->_C_bufsize ? - this->_C_bufsize * _RWSTD_NEW_CAPACITY_RATIO - : _RWSTD_MINIMUM_STRINGBUF_CAPACITY); + this->_C_bufsize ? + (this->_C_bufsize >> 10) * __ratio + + (((this->_C_bufsize & 0x3ff) * __ratio) >> 10) + : _RWSTD_MINIMUM_STRINGBUF_CAPACITY; return __cap < __to ? __to : __cap; } Modified: incubator/stdcxx/trunk/include/string URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/string?rev=605550&r1=605549&r2=605550&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/string (original) +++ incubator/stdcxx/trunk/include/string Wed Dec 19 06:28:28 2007 @@ -1535,8 +1535,12 @@ { typedef _RWSTD_STRING_SIZE_TYPE _RWSizeT; - _RWSizeT __cap = - _RWSTD_STATIC_CAST (_RWSizeT, __size * _RWSTD_STRING_CAPACITY_RATIO); + const _RWSizeT __ratio = _RWSizeT ( (_RWSTD_STRING_CAPACITY_RATIO << 10) + / _RWSTD_RATIO_DIVIDER); + + const _RWSizeT __cap = (__size >> 10) * __ratio + + (((__size & 0x3ff) * __ratio) >> 10); + return (__size += _RWSTD_MINIMUM_STRING_CAPACITY) > __cap ? __size : __cap; } @@ -1557,9 +1561,14 @@ __rw_new_capacity (_RWSTD_STRING_SIZE_TYPE (_STD::string) __size, const _STD::string*) { - _RWSTD_STRING_SIZE_TYPE (_STD::string) __cap = - _RWSTD_STATIC_CAST (_RWSTD_STRING_SIZE_TYPE (_STD::string), - __size * _RWSTD_STRING_CAPACITY_RATIO); + typedef _RWSTD_STRING_SIZE_TYPE (_STD::string) _RWSizeT; + + const _RWSizeT __ratio = _RWSizeT ( (_RWSTD_STRING_CAPACITY_RATIO << 10) + / _RWSTD_RATIO_DIVIDER); + + const _RWSizeT __cap = (__size >> 10) * __ratio + + (((__size & 0x3ff) * __ratio) >> 10); + return (__size += _RWSTD_MINIMUM_STRING_CAPACITY) > __cap ? __size : __cap; } @@ -1568,9 +1577,14 @@ __rw_new_capacity (_RWSTD_STRING_SIZE_TYPE (_STD::wstring) __size, const _STD::wstring*) { - _RWSTD_STRING_SIZE_TYPE (_STD::wstring) __cap = - _RWSTD_STATIC_CAST (_RWSTD_STRING_SIZE_TYPE (_STD::wstring), - __size * _RWSTD_STRING_CAPACITY_RATIO); + typedef _RWSTD_STRING_SIZE_TYPE (_STD::wstring) _RWSizeT; + + const _RWSizeT __ratio = _RWSizeT ( (_RWSTD_STRING_CAPACITY_RATIO << 10) + / _RWSTD_RATIO_DIVIDER); + + const _RWSizeT __cap = (__size >> 10) * __ratio + + (((__size & 0x3ff) * __ratio) >> 10); + return (__size += _RWSTD_MINIMUM_STRING_CAPACITY) > __cap ? __size : __cap; }