[llvm] [clang] Deduplicate the logic between StringMapEntry.first() and StringMapEntry.getKey() (PR #113735)
Boaz Brickner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 28 06:39:48 PDT 2024
https://github.com/bricknerb updated https://github.com/llvm/llvm-project/pull/113735
>From cf1ff225026cce406fb54f6e11514dcf61ca8def Mon Sep 17 00:00:00 2001
From: Boaz Brickner <brickner at google.com>
Date: Fri, 25 Oct 2024 21:48:08 +0200
Subject: [PATCH 1/2] [clang] Deduplicate the logic between
StringMapEntry.first() and StringMapEntry.getKey().
---
llvm/include/llvm/ADT/StringMapEntry.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
index 98b51cc1aebd59..a3ff2415869be6 100644
--- a/llvm/include/llvm/ADT/StringMapEntry.h
+++ b/llvm/include/llvm/ADT/StringMapEntry.h
@@ -117,7 +117,7 @@ class StringMapEntry final : public StringMapEntryStorage<ValueTy> {
}
StringRef first() const {
- return StringRef(getKeyData(), this->getKeyLength());
+ return getKey();
}
/// Create a StringMapEntry for the specified key construct the value using
>From 1b15765c6f9a69c1e7bf3119109ae46325e7b05b Mon Sep 17 00:00:00 2001
From: Boaz Brickner <brickner at google.com>
Date: Fri, 25 Oct 2024 22:12:55 +0200
Subject: [PATCH 2/2] [clang] Fix StringMapEntry.first() formatting.
---
llvm/include/llvm/ADT/StringMapEntry.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
index a3ff2415869be6..d93af5aedc39d7 100644
--- a/llvm/include/llvm/ADT/StringMapEntry.h
+++ b/llvm/include/llvm/ADT/StringMapEntry.h
@@ -116,9 +116,7 @@ class StringMapEntry final : public StringMapEntryStorage<ValueTy> {
return reinterpret_cast<const char *>(this + 1);
}
- StringRef first() const {
- return getKey();
- }
+ StringRef first() const { return getKey(); }
/// Create a StringMapEntry for the specified key construct the value using
/// \p InitiVals.
More information about the llvm-commits
mailing list