[llvm] fc2b09a - [ADT] Remove ImmutableSet::foreach and ImmutableMap::foreach (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 1 22:05:32 PST 2022
Author: Kazu Hirata
Date: 2022-01-01T22:05:14-08:00
New Revision: fc2b09a744dca3c995a6cc82482f135e1e4e41ef
URL: https://github.com/llvm/llvm-project/commit/fc2b09a744dca3c995a6cc82482f135e1e4e41ef
DIFF: https://github.com/llvm/llvm-project/commit/fc2b09a744dca3c995a6cc82482f135e1e4e41ef.diff
LOG: [ADT] Remove ImmutableSet::foreach and ImmutableMap::foreach (NFC)
These functions seem to be unused for at least 1 year.
Added:
Modified:
llvm/include/llvm/ADT/ImmutableMap.h
llvm/include/llvm/ADT/ImmutableSet.h
llvm/unittests/ADT/ImmutableSetTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/ImmutableMap.h b/llvm/include/llvm/ADT/ImmutableMap.h
index cf6fb870897ae..f0e898cafaf94 100644
--- a/llvm/include/llvm/ADT/ImmutableMap.h
+++ b/llvm/include/llvm/ADT/ImmutableMap.h
@@ -140,44 +140,7 @@ class ImmutableMap {
bool isEmpty() const { return !Root; }
- //===--------------------------------------------------===//
- // Foreach - A limited form of map iteration.
- //===--------------------------------------------------===//
-
-private:
- template <typename Callback>
- struct CBWrapper {
- Callback C;
-
- void operator()(value_type_ref V) { C(V.first,V.second); }
- };
-
- template <typename Callback>
- struct CBWrapperRef {
- Callback &C;
-
- CBWrapperRef(Callback& c) : C(c) {}
-
- void operator()(value_type_ref V) { C(V.first,V.second); }
- };
-
public:
- template <typename Callback>
- void foreach(Callback& C) {
- if (Root) {
- CBWrapperRef<Callback> CB(C);
- Root->foreach(CB);
- }
- }
-
- template <typename Callback>
- void foreach() {
- if (Root) {
- CBWrapper<Callback> CB;
- Root->foreach(CB);
- }
- }
-
//===--------------------------------------------------===//
// For testing.
//===--------------------------------------------------===//
diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h
index 48b253d3b75e7..8cef5acbafaaf 100644
--- a/llvm/include/llvm/ADT/ImmutableSet.h
+++ b/llvm/include/llvm/ADT/ImmutableSet.h
@@ -169,20 +169,6 @@ class ImutAVLTree {
/// is logarithmic in the size of the tree.
bool contains(key_type_ref K) { return (bool) find(K); }
- /// foreach - A member template the accepts invokes operator() on a functor
- /// object (specified by Callback) for every node/subtree in the tree.
- /// Nodes are visited using an inorder traversal.
- template <typename Callback>
- void foreach(Callback& C) {
- if (ImutAVLTree* L = getLeft())
- L->foreach(C);
-
- C(value);
-
- if (ImutAVLTree* R = getRight())
- R->foreach(C);
- }
-
/// validateTree - A utility method that checks that the balancing and
/// ordering invariants of the tree are satisfied. It is a recursive
/// method that returns the height of the tree, which is then consumed
@@ -1063,12 +1049,6 @@ class ImmutableSet {
/// This method runs in constant time.
bool isSingleton() const { return getHeight() == 1; }
- template <typename Callback>
- void foreach(Callback& C) { if (Root) Root->foreach(C); }
-
- template <typename Callback>
- void foreach() { if (Root) { Callback C; Root->foreach(C); } }
-
//===--------------------------------------------------===//
// Iterators.
//===--------------------------------------------------===//
diff --git a/llvm/unittests/ADT/ImmutableSetTest.cpp b/llvm/unittests/ADT/ImmutableSetTest.cpp
index e23cd2b3d1a81..c0bde4c4d680b 100644
--- a/llvm/unittests/ADT/ImmutableSetTest.cpp
+++ b/llvm/unittests/ADT/ImmutableSetTest.cpp
@@ -136,41 +136,6 @@ TEST_F(ImmutableSetTest, RemoveIntSetTest) {
EXPECT_TRUE(S4.contains(5));
}
-TEST_F(ImmutableSetTest, CallbackCharSetTest) {
- ImmutableSet<char>::Factory f;
- ImmutableSet<char> S = f.getEmptySet();
-
- ImmutableSet<char> S2 = f.add(f.add(f.add(S, 'a'), 'e'), 'i');
- ImmutableSet<char> S3 = f.add(f.add(S2, 'o'), 'u');
-
- S3.foreach<MyIter>();
-
- ASSERT_STREQ("aeiou", buffer);
-}
-
-TEST_F(ImmutableSetTest, Callback2CharSetTest) {
- ImmutableSet<char>::Factory f;
- ImmutableSet<char> S = f.getEmptySet();
-
- ImmutableSet<char> S2 = f.add(f.add(f.add(S, 'b'), 'c'), 'd');
- ImmutableSet<char> S3 = f.add(f.add(f.add(S2, 'f'), 'g'), 'h');
-
- MyIter obj;
- S3.foreach<MyIter>(obj);
- ASSERT_STREQ("bcdfgh", buffer);
- ASSERT_EQ(6, obj.counter);
-
- MyIter obj2;
- S2.foreach<MyIter>(obj2);
- ASSERT_STREQ("bcd", buffer);
- ASSERT_EQ(3, obj2.counter);
-
- MyIter obj3;
- S.foreach<MyIter>(obj);
- ASSERT_STREQ("", buffer);
- ASSERT_EQ(0, obj3.counter);
-}
-
TEST_F(ImmutableSetTest, IterLongSetTest) {
ImmutableSet<long>::Factory f;
ImmutableSet<long> S = f.getEmptySet();
More information about the llvm-commits
mailing list