[lld] r228069 - Avoid two function calls of file() when not needed.
Davide Italiano
davide at freebsd.org
Tue Feb 3 16:10:49 PST 2015
On Tue, Feb 3, 2015 at 4:01 PM, Rui Ueyama <ruiu at google.com> wrote:
> On Tue, Feb 3, 2015 at 3:44 PM, Davide Italiano <davide at freebsd.org> wrote:
>>
>> Author: davide
>> Date: Tue Feb 3 17:44:33 2015
>> New Revision: 228069
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=228069&view=rev
>> Log:
>> Avoid two function calls of file() when not needed.
>>
>> Reported by: ruiu
>>
>> Modified:
>> lld/trunk/lib/Core/DefinedAtom.cpp
>>
>> Modified: lld/trunk/lib/Core/DefinedAtom.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/DefinedAtom.cpp?rev=228069&r1=228068&r2=228069&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/lib/Core/DefinedAtom.cpp (original)
>> +++ lld/trunk/lib/Core/DefinedAtom.cpp Tue Feb 3 17:44:33 2015
>> @@ -83,12 +83,15 @@ DefinedAtom::ContentPermissions DefinedA
>>
>> bool DefinedAtom::compareByPosition(const DefinedAtom *lhs,
>> const DefinedAtom *rhs) {
>> - const File *lhsFile = &lhs->file();
>> - const File *rhsFile = &rhs->file();
>> + const File *lhsFile;
>> + const File *rhsFile;
>>
>> if (lhs == rhs)
>> return false;
>>
>> + lhsFile = &lhs->file();
>> + rhsFile = &rhs->file();
>> +
>> if (lhsFile->ordinal() != rhsFile->ordinal())
>> return lhsFile->ordinal() < rhsFile->ordinal();
>> assert(lhs->ordinal() != rhs->ordinal());
>
>
> Oh, the new code looks like too C89-ish. You could have intermingled
> declarations and code like this. It's better to do pre-commit code review,
> perhaps?
>
FWIW, I haven't seen anything against that in
http://llvm.org/docs/CodingStandards.html , unless I overlooked (which
might be possible).
I can change that again if you really want.
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list