[llvm] 29b2b22 - [TargetParser] Use StringRef::consume_front (NFC) (#147202)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 6 19:05:49 PDT 2025
Author: Kazu Hirata
Date: 2025-07-06T19:05:45-07:00
New Revision: 29b2b2263f9eb7b310ee38628e43be76f2c9caf4
URL: https://github.com/llvm/llvm-project/commit/29b2b2263f9eb7b310ee38628e43be76f2c9caf4
DIFF: https://github.com/llvm/llvm-project/commit/29b2b2263f9eb7b310ee38628e43be76f2c9caf4.diff
LOG: [TargetParser] Use StringRef::consume_front (NFC) (#147202)
While we are at it, this patch switches to a range-based for loop.
Added:
Modified:
llvm/lib/TargetParser/Host.cpp
Removed:
################################################################################
diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 5957e1befe2da..e668d69a133d3 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -180,13 +180,13 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
StringRef Implementer;
StringRef Hardware;
StringRef Part;
- for (unsigned I = 0, E = Lines.size(); I != E; ++I) {
- if (Lines[I].starts_with("CPU implementer"))
- Implementer = Lines[I].substr(15).ltrim("\t :");
- if (Lines[I].starts_with("Hardware"))
- Hardware = Lines[I].substr(8).ltrim("\t :");
- if (Lines[I].starts_with("CPU part"))
- Part = Lines[I].substr(8).ltrim("\t :");
+ for (StringRef Line : Lines) {
+ if (Line.consume_front("CPU implementer"))
+ Implementer = Line.ltrim("\t :");
+ else if (Line.consume_front("Hardware"))
+ Hardware = Line.ltrim("\t :");
+ else if (Line.consume_front("CPU part"))
+ Part = Line.ltrim("\t :");
}
if (Implementer == "0x41") { // ARM Ltd.
More information about the llvm-commits
mailing list