diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-01 21:08:12 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-01 21:08:12 -0500 |
| commit | f6cbb73c7402fc100bbfb26c1a35c9f23b3f36ff (patch) | |
| tree | 6d62eb0f6b04292b98ef2bd92b40699a6c32da0a /src/hash_map.hpp | |
| parent | c6ace9720c8666f893f236c00ea9b370b1b2bb70 (diff) | |
| download | zig-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.hpp | 9 |
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) |
