================
@@ -63,32 +63,32 @@ enum class JoinKind {
Asymmetric,
};
-/// Computes the key-wise union of two ImmutableMaps.
+/// Computes the key-wise union of two ImmutableMaps. Templated on the map type
+/// so the key, value, value-info and canonicalization parameters need not be
+/// spelled out.
// TODO(opt): This key-wise join is a performance bottleneck. A more
// efficient merge could be implemented using a Patricia Trie or HAMT
// instead of the current AVL-tree-based ImmutableMap.
-template <typename K, typename V, typename Joiner>
-llvm::ImmutableMap<K, V> join(const llvm::ImmutableMap<K, V> &A,
- const llvm::ImmutableMap<K, V> &B,
- typename llvm::ImmutableMap<K, V>::Factory &F,
- Joiner JoinValues, JoinKind Kind) {
+template <typename MapT, typename Joiner>
+MapT join(const MapT &A, const MapT &B, typename MapT::Factory &F,
+ Joiner JoinValues, JoinKind Kind) {
if (A.getRootWithoutRetain() == B.getRootWithoutRetain())
return A;
if (A.getHeight() < B.getHeight())
return join(B, A, F, JoinValues, Kind);
// For each element in B, join it with the corresponding element in A
// (or with an empty value if it doesn't exist in A).
- llvm::ImmutableMap<K, V> Res = A;
+ MapT Res = A;
for (const auto &Entry : B) {
- const K &Key = Entry.first;
- const V &ValB = Entry.second;
+ const auto &Key = Entry.first;
+ const auto &ValB = Entry.second;
----------------
Xazax-hun wrote:
Done.
https://github.com/llvm/llvm-project/pull/209300
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits