diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-04-17 01:02:29 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-04-17 01:02:29 +0200 |
commit | 12b7eefbc5cc80ab0bc2db6c576a4b15574cacd6 (patch) | |
tree | 39214b917af2cce362dcaa7f145ea396800e3425 /src/libexpr/symbol-table.hh | |
parent | 7a9687ba30d579bc51e0aaf3193e0ab8d86400d2 (diff) |
nix flake show: Use evaluation cache
Diffstat (limited to 'src/libexpr/symbol-table.hh')
-rw-r--r-- | src/libexpr/symbol-table.hh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libexpr/symbol-table.hh b/src/libexpr/symbol-table.hh index 7ba5e1c14..4eb6dac81 100644 --- a/src/libexpr/symbol-table.hh +++ b/src/libexpr/symbol-table.hh @@ -28,6 +28,12 @@ public: return s == s2.s; } + // FIXME: remove + bool operator == (std::string_view s2) const + { + return s->compare(s2) == 0; + } + bool operator != (const Symbol & s2) const { return s != s2.s; @@ -68,9 +74,10 @@ private: Symbols symbols; public: - Symbol create(const string & s) + Symbol create(std::string_view s) { - std::pair<Symbols::iterator, bool> res = symbols.insert(s); + // FIXME: avoid allocation if 's' already exists in the symbol table. + std::pair<Symbols::iterator, bool> res = symbols.emplace(std::string(s)); return Symbol(&*res.first); } |