bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/19793] script-sections.cc:1475: possible redundant string copy


From: ccoutant at gmail dot com
Subject: [Bug gold/19793] script-sections.cc:1475: possible redundant string copy ?
Date: Sat, 12 Mar 2016 19:21:42 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=19793

Cary Coutant <ccoutant at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #2 from Cary Coutant <ccoutant at gmail dot com> ---
Upon further reflection, I've decided that the suggested change is good.

(1) Inlining doesn't make any difference at all. (Not sure what I was thinking
when I wrote that.)

(2) The "if you're going to copy it, pass it by value and let the compiler make
the copy" rule only applies if the function is making a local copy to modify.
That's not the case here -- we're simply assigning it to a data member.

(3) The third reason is still valid -- because we're passing a temporary at the
point of call, there really are no extra copies made and the code is basically
identical as if we had passed by const reference. But passing by const
reference is no worse in this case, and will be better if we ever modify the
code at the point of call such that the argument passed is no longer a
temporary.

There are a few other places in gold where we should also pass by const
reference instead of value for std::string.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]