[llvm] Add StringMap::lookup() overload to take a default value and return a reference to the value to avoid a copy (PR #115469)

Boaz Brickner via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 26 08:40:26 PST 2024


================
@@ -257,6 +257,15 @@ class LLVM_ALLOCATORHOLDER_EMPTYBASE StringMap
     return ValueTy();
   }
 
+  /// lookup - Return the entry for the specified key, or a default
+  /// provided value if no such entry exists.
+  const ValueTy &lookup(StringRef Key, const ValueTy& Value) const {
----------------
bricknerb wrote:

Thanks everyone!
I agree this API is not ideal and might require a stronger use case to introduce, so closing this PR.

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


More information about the llvm-commits mailing list