[lld] r332952 - [ELF] Simplify. NFC

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed May 23 00:43:38 PDT 2018


>> OK.
>>
>> if (Name.startswith(Prefix))
>>   DoSomethingWith(Name.substr(Prefix.size())))
>>
>> should be acceptable. What if an integer constant is used?
>>
>> if (Name.startswith("__start_"))
>>   DoSomethingWith(Name.substr(8)))
>>
>
>I can't speak for everybody, but I do accept that as long as it is obvious
>what you are trying to do with the code.

FWIW, I would leave original code.

Approach with using integer constants seems would remove the loop and
make the code a bit larger, though not more readable (IMO).

And what is currently committed (r332952) makes me wonder if it is really NFC.
I think it should be technically possible to have a symbol with a name like "__start___stop_xxx",
and then because of string mutation in a loop, we would end up with adding "__stop_xxx" and "xxx" to
UsedStartStop it seems. I would not need to think about it if the string was immutable. And what is bad
that name `consume_front` does not give an explicit hint that it is mutated.

George.


More information about the llvm-commits mailing list