Skip to content

Commit 29b2b22

Browse files
[TargetParser] Use StringRef::consume_front (NFC) (#147202)
While we are at it, this patch switches to a range-based for loop.
1 parent eca05fd commit 29b2b22

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/TargetParser/Host.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
180180
StringRef Implementer;
181181
StringRef Hardware;
182182
StringRef Part;
183-
for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
184-
if (Lines[I].starts_with("CPU implementer"))
185-
Implementer = Lines[I].substr(15).ltrim("\t :");
186-
if (Lines[I].starts_with("Hardware"))
187-
Hardware = Lines[I].substr(8).ltrim("\t :");
188-
if (Lines[I].starts_with("CPU part"))
189-
Part = Lines[I].substr(8).ltrim("\t :");
183+
for (StringRef Line : Lines) {
184+
if (Line.consume_front("CPU implementer"))
185+
Implementer = Line.ltrim("\t :");
186+
else if (Line.consume_front("Hardware"))
187+
Hardware = Line.ltrim("\t :");
188+
else if (Line.consume_front("CPU part"))
189+
Part = Line.ltrim("\t :");
190190
}
191191

192192
if (Implementer == "0x41") { // ARM Ltd.

0 commit comments

Comments
 (0)