This is the mail archive of the 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 Mon, May 18, 2015 at 09:07:43PM +0300, 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>);

I believe that transformation is considered obvious, so you can just go
ahead and commit all the parts that are just that.  That should make
reviewers lives much simpler ;-)

> 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.

I haven't looked at the cases where you removed functions, but I suspect
you can call those obvious too, and save yourself any rebasing pain.



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