diff options
author | Kazu Hirata <kazu@google.com> | 2024-08-25 11:30:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 11:30:49 -0700 |
commit | 33e7cd6ff23f6c904314d17c68dc58168fd32d09 (patch) | |
tree | 544969f067771e290d1c729ab896219dc1da135e /llvm/lib/Object | |
parent | 33f3ebc86e7d3afcb65c551feba5bbc2421b42ed (diff) | |
download | llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.zip llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.tar.gz llvm-33e7cd6ff23f6c904314d17c68dc58168fd32d09.tar.bz2 |
[llvm] Prefer StringRef::substr to StringRef::slice (NFC) (#105943)
S.substr(N) is simpler than S.slice(N, StringRef::npos) and
S.slice(N, S.size()). Also, substr is probably better recognizable
than slice thanks to std::string_view::substr.
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index bd9b5dd1..6f3dd4d 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -2436,12 +2436,12 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name, a = Name.rfind('/'); if (a == Name.npos || a == 0) goto guess_library; - Foo = Name.slice(a+1, Name.npos); + Foo = Name.substr(a + 1); // Look for a suffix starting with a '_' Idx = Foo.rfind('_'); if (Idx != Foo.npos && Foo.size() >= 2) { - Suffix = Foo.slice(Idx, Foo.npos); + Suffix = Foo.substr(Idx); if (Suffix != "_debug" && Suffix != "_profile") Suffix = StringRef(); else @@ -2468,7 +2468,7 @@ StringRef MachOObjectFile::guessLibraryShortName(StringRef Name, c = Name.rfind('/', b); if (c == Name.npos || c == 0) goto guess_library; - V = Name.slice(c+1, Name.npos); + V = Name.substr(c + 1); if (!V.starts_with("Versions/")) goto guess_library; d = Name.rfind('/', c); @@ -2489,7 +2489,7 @@ guess_library: a = Name.rfind('.'); if (a == Name.npos || a == 0) return StringRef(); - Dylib = Name.slice(a, Name.npos); + Dylib = Name.substr(a); if (Dylib != ".dylib") goto guess_qtx; @@ -2527,7 +2527,7 @@ guess_library: return Lib; guess_qtx: - Qtx = Name.slice(a, Name.npos); + Qtx = Name.substr(a); if (Qtx != ".qtx") return StringRef(); b = Name.rfind('/', a); |