This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/51965] Redundant move constructions in heap algorithms


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]