This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/51965] Redundant move constructions in heap algorithms
- From: "marc.glisse at normalesup dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Jan 2012 23:18:20 +0000
- Subject: [Bug libstdc++/51965] Redundant move constructions in heap algorithms
- Auto-submitted: auto-generated
- References: <bug-51965-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51965
Marc Glisse <marc.glisse at normalesup dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marc.glisse at normalesup
| |dot org
--- Comment #5 from Marc Glisse <marc.glisse at normalesup dot org> 2012-01-23 23:18:20 UTC ---
(The split into push_heap and __push_heap is just so the first part can be
inlined without the second, right?)
A more direct adaptation of the old code to rvalue references would be:
std::__push_heap(__first, _DistanceType((__last - __first) - 1),
_DistanceType(0), _ValueType(_GLIBCXX_MOVE(*(__last -
1))));
Without the named temporary value, the compiler can perform copy elision.
Aliaksandr's patch looks like a different way to achieve the same goal.
Note that the current code thus seems to have a performance regression in C++03
compared to before the introduction of moves.