This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Replace strlen with StringRef::size
AcceptedPublic

Authored by 1lyasm on Mar 19 2023, 2:07 PM.

Details

Summary

Replace multiple strlen calls with a StringRef constructor and a StringRef::size call.
Rename ArgSize to SpellingSize, and add ArgStringSize.

Diff Detail

Event Timeline

1lyasm created this revision.Mar 19 2023, 2:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2023, 2:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
1lyasm requested review of this revision.Mar 19 2023, 2:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2023, 2:07 PM

Renamed ArgSize to SpellingSize, because both ArgSize and ArgStringSize would be confusing

vitalybuka accepted this revision.Mar 20 2023, 2:05 PM
vitalybuka retitled this revision from Replace strlen with StringRef::size to [NFC] Replace strlen with StringRef::size.
This revision is now accepted and ready to land.Mar 20 2023, 2:05 PM

I do not have commit access, can you commit this for me?
(Ilyas Mustafazade <il.mystafa@gmail.com>)

vitalybuka added inline comments.
llvm/lib/Option/Option.cpp
208

@hans do you know what this TODO is about, https://reviews.llvm.org/D1387
If this is about performance, we still have strlen in StringRef

I've spitted the patch in 2

vitalybuka reopened this revision.Mar 20 2023, 2:21 PM
This revision is now accepted and ready to land.Mar 20 2023, 2:21 PM
vitalybuka accepted this revision.Mar 20 2023, 2:21 PM
hans added inline comments.Mar 21 2023, 3:12 AM
llvm/lib/Option/Option.cpp
208

I just copied it from the other flag classes. The FIXMEs were added in https://github.com/llvm/llvm-project/commit/458b6982d471992337639382cdac1bb30311b4c0

I'm guessing the author figured the sizes should already be known (I think the ArgList is storing StringRefs maybe?) and the strlen shouldn't really be needed.

I think that's a minor detail, but one day it would be nice to modernize the whole options framework and use less char pointers.