[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sun May 19 16:07:05 PDT 2024


================
@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) {
   llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path),
     E = llvm::sys::path::end(Path);
   while (B != E) {
-    if (B->compare(".") == 0) {
-    }
-    else if (B->compare("..") == 0)
+    if (*B == ".") {
+    } else if (*B == "..")
       llvm::sys::path::remove_filename(Buffer);
     else
----------------
MaskRay wrote:

Refactor this to `else if (*B != ".")`

https://github.com/llvm/llvm-project/pull/92708


More information about the cfe-commits mailing list