[PATCH] Remove redundant std::move on const object
Jonathan Wakely
jwakely@redhat.com
Wed Jun 6 19:37:00 GMT 2018
This parameter is a reference-to-const so moving it doesn't do
anything. Allocators should be cheap to copy anyway.
* include/bits/shared_ptr_base.h (__shared_count): Remove redundant
move of const value.
Tested powerpc64le-linux, committed to trunk.
-------------- next part --------------
commit 11b524858a52ef3f22b515c5a0320bbbae7be597
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Jun 6 15:54:01 2018 +0100
Remove redundant std::move on const object
* include/bits/shared_ptr_base.h (__shared_count): Remove redundant
move of const value.
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 6c5089afdda..887edbd7879 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -534,6 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public:
using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
+ // Alloc parameter is not a reference so doesn't alias anything in __args
template<typename... _Args>
_Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
: _M_impl(__a)
@@ -653,8 +654,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename _Sp_cp_type::__allocator_type __a2(__a);
auto __guard = std::__allocate_guarded(__a2);
_Sp_cp_type* __mem = __guard.get();
- ::new (__mem) _Sp_cp_type(std::move(__a),
- std::forward<_Args>(__args)...);
+ ::new (__mem) _Sp_cp_type(__a, std::forward<_Args>(__args)...);
_M_pi = __mem;
__guard = nullptr;
}
More information about the Libstdc++
mailing list