aboutsummaryrefslogtreecommitdiff
path: root/src/hash_map.hpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-01 21:08:12 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-01 21:08:12 -0500
commitf6cbb73c7402fc100bbfb26c1a35c9f23b3f36ff (patch)
tree6d62eb0f6b04292b98ef2bd92b40699a6c32da0a /src/hash_map.hpp
parentc6ace9720c8666f893f236c00ea9b370b1b2bb70 (diff)
downloadzig-f6cbb73c7402fc100bbfb26c1a35c9f23b3f36ff.tar.gz
zig-f6cbb73c7402fc100bbfb26c1a35c9f23b3f36ff.zip
rewrite scope implementation
* now there are not extra unused hash tables * each variable declaration opens a new scope inside a function
Diffstat (limited to 'src/hash_map.hpp')
-rw-r--r--src/hash_map.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/hash_map.hpp b/src/hash_map.hpp
index 9c9939e4cc..51ec352eda 100644
--- a/src/hash_map.hpp
+++ b/src/hash_map.hpp
@@ -61,6 +61,15 @@ public:
}
}
+ Entry *put_unique(const K &key, const V &value) {
+ // TODO make this more efficient
+ Entry *entry = internal_get(key);
+ if (entry)
+ return entry;
+ put(key, value);
+ return nullptr;
+ }
+
const V &get(const K &key) const {
Entry *entry = internal_get(key);
if (!entry)