PR libstdc++/30416 (continued)
2007-01-12 Paolo Carlini <pcarlini@suse.de> PR libstdc++/30416 (continued) * include/std/valarray (valarray<>::shift, valarray<>::cshift): Allways return the same variable, thus facilitating NRVO. From-SVN: r120722
This commit is contained in:
parent
f005dd79c5
commit
102693c7de
2 changed files with 25 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
|||
2007-01-12 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/30416 (continued)
|
||||
* include/std/valarray (valarray<>::shift, valarray<>::cshift):
|
||||
Allways return the same variable, thus facilitating NRVO.
|
||||
|
||||
2007-01-12 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/30416
|
||||
|
|
|
@ -782,14 +782,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
inline valarray<_Tp>
|
||||
valarray<_Tp>::shift(int __n) const
|
||||
{
|
||||
if (_M_size == 0 || __n == 0)
|
||||
return *this;
|
||||
|
||||
valarray<_Tp> __ret;
|
||||
|
||||
if (_M_size == 0)
|
||||
return __ret;
|
||||
|
||||
_Tp* __restrict__ __tmp_M_data =
|
||||
std::__valarray_get_storage<_Tp>(_M_size);
|
||||
|
||||
if (__n > 0) // shift left
|
||||
if (__n == 0)
|
||||
std::__valarray_copy_construct(_M_data,
|
||||
_M_data + _M_size, __tmp_M_data);
|
||||
else if (__n > 0) // shift left
|
||||
{
|
||||
if (size_t(__n) > _M_size)
|
||||
__n = _M_size;
|
||||
|
@ -799,7 +803,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
std::__valarray_default_construct(__tmp_M_data + _M_size - __n,
|
||||
__tmp_M_data + _M_size);
|
||||
}
|
||||
else // shift right
|
||||
else // shift right
|
||||
{
|
||||
if (size_t(-__n) > _M_size)
|
||||
__n = -_M_size;
|
||||
|
@ -819,14 +823,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
inline valarray<_Tp>
|
||||
valarray<_Tp>::cshift(int __n) const
|
||||
{
|
||||
if (_M_size == 0 || __n == 0)
|
||||
return *this;
|
||||
|
||||
valarray<_Tp> __ret;
|
||||
|
||||
if (_M_size == 0)
|
||||
return __ret;
|
||||
|
||||
_Tp* __restrict__ __tmp_M_data =
|
||||
std::__valarray_get_storage<_Tp>(_M_size);
|
||||
|
||||
if (__n > 0) // cshift left
|
||||
|
||||
if (__n == 0)
|
||||
std::__valarray_copy_construct(_M_data,
|
||||
_M_data + _M_size, __tmp_M_data);
|
||||
else if (__n > 0) // cshift left
|
||||
{
|
||||
if (size_t(__n) > _M_size)
|
||||
__n = __n % _M_size;
|
||||
|
@ -836,7 +844,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
|
||||
__tmp_M_data);
|
||||
}
|
||||
else // cshift right
|
||||
else // cshift right
|
||||
{
|
||||
if (size_t(-__n) > _M_size)
|
||||
__n = -(-__n % _M_size);
|
||||
|
|
Loading…
Add table
Reference in a new issue