From 8b8a7fcf68c3bb6f8b90f5f1813ebb391b56e550 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 3 Sep 2009 22:07:30 +0000 Subject: Make ImmutableMap/ImmutableSet quicker by only canonicalizing the tree after an Add or Remove operation complete, and not while building the intermediate tree. This trades a little bit more memory usage for less accesses to the FoldingSet. On a benchmark for the clang static analyzer, this shaves off another 13% of execution time when using field/array sensitivity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80955 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ImmutableMap.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/llvm/ADT/ImmutableMap.h') diff --git a/include/llvm/ADT/ImmutableMap.h b/include/llvm/ADT/ImmutableMap.h index 52708bc..96bf012 100644 --- a/include/llvm/ADT/ImmutableMap.h +++ b/include/llvm/ADT/ImmutableMap.h @@ -90,12 +90,13 @@ public: 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(K,D))); + TreeTy *T = F.Add(Old.Root, std::make_pair(K,D)); + return ImmutableMap(F.GetCanonicalTree(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(F.GetCanonicalTree(T)); } private: -- cgit v1.1