summaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/ImmutableMap.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT/ImmutableMap.h')
-rw-r--r--include/llvm/ADT/ImmutableMap.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/include/llvm/ADT/ImmutableMap.h b/include/llvm/ADT/ImmutableMap.h
index 52708bc..742e232 100644
--- a/include/llvm/ADT/ImmutableMap.h
+++ b/include/llvm/ADT/ImmutableMap.h
@@ -80,22 +80,25 @@ public:
class Factory {
typename TreeTy::Factory F;
+ const bool Canonicalize;
public:
- Factory() {}
-
- Factory(BumpPtrAllocator& Alloc)
- : F(Alloc) {}
+ Factory(bool canonicalize = true)
+ : Canonicalize(canonicalize) {}
+
+ Factory(BumpPtrAllocator& Alloc, bool canonicalize = true)
+ : F(Alloc), Canonicalize(canonicalize) {}
ImmutableMap GetEmptyMap() { return ImmutableMap(F.GetEmptyTree()); }
ImmutableMap Add(ImmutableMap Old, key_type_ref K, data_type_ref D) {
- return ImmutableMap(F.Add(Old.Root,
- std::make_pair<key_type,data_type>(K,D)));
+ TreeTy *T = F.Add(Old.Root, std::make_pair<key_type,data_type>(K,D));
+ return ImmutableMap(Canonicalize ? F.GetCanonicalTree(T): T);
}
ImmutableMap Remove(ImmutableMap Old, key_type_ref K) {
- return ImmutableMap(F.Remove(Old.Root,K));
+ TreeTy *T = F.Remove(Old.Root,K);
+ return ImmutableMap(Canonicalize ? F.GetCanonicalTree(T): T);
}
private:
OpenPOWER on IntegriCloud