This is the mail archive of the gcc-patches@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]

Re: [PATCH] Refactoring: use std::swap instead of manual swaps


On 05/18/2015 12:07 PM, Mikhail Maltsev wrote:
Hi all.
The attached patch replaces the following typical sequence of
assignments, matching the pattern:

[type] <temp_var> = <value1>;
<value1> = <value2>;
<value2> = <temp_var>;

with

std::swap (<value1>, <value2>);

The goal is to improve code readability (at least a little).

Pattern was searched in GCC tree using a script, but all modifications
have been done manually to make sure that removing assignment to
<temp_var> does not modify the behavior of the code. Where possible,
temporary variables were removed or moved to blocks with narrower scope.
I also removed a couple of pre-C++ implementations of swap function and
one implementation of std::reverse.

Bootstrapped/regtested on x86_64 linux (multilib). Test for "broken
builds" currently running. I will also run test on a couple of
simulators (though currently there is a problem with build:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66181).

OK for trunk after complete test?

Did you mean to lose the assignment to heapa->m_nodes in fibonacci_heap.h?

I just spot-checked and it looks fine to me, except for perhaps losing the assignment noted above.

jeff


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