[llvm] [ADT] Delegate to DenseMap::find_as (NFC) (PR #155974)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 22:18:00 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/155974
DenseMap::find is a special case of DenseMap::find_as with a
restriction on the key type.
>From 5674cb8cb768ae39b3d32abfe32c9b2c79984f4b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 28 Aug 2025 08:24:21 -0700
Subject: [PATCH] [ADT] Delegate to DenseMap::find_as (NFC)
DenseMap::find is a special case of DenseMap::find_as with a
restriction on the key type.
---
llvm/include/llvm/ADT/DenseMap.h | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index c44706a597fa6..3e59f843e0bee 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -174,20 +174,8 @@ class DenseMapBase : public DebugEpochBase {
return contains(Val) ? 1 : 0;
}
- iterator find(const_arg_type_t<KeyT> Val) {
- if (BucketT *Bucket = doFind(Val))
- return makeIterator(
- Bucket, shouldReverseIterate<KeyT>() ? getBuckets() : getBucketsEnd(),
- *this, true);
- return end();
- }
- const_iterator find(const_arg_type_t<KeyT> Val) const {
- if (const BucketT *Bucket = doFind(Val))
- return makeConstIterator(
- Bucket, shouldReverseIterate<KeyT>() ? getBuckets() : getBucketsEnd(),
- *this, true);
- return end();
- }
+ iterator find(const_arg_type_t<KeyT> Val) { return find_as(Val); }
+ const_iterator find(const_arg_type_t<KeyT> Val) const { return find_as(Val); }
/// Alternate version of find() which allows a different, and possibly
/// less expensive, key type.
More information about the llvm-commits
mailing list