aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/symbol-table.hh
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-20 17:29:23 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-07-20 17:29:23 +0000
commiteab945f5910748597f7b2d02c93117fece788c50 (patch)
tree7609e69bbafc25845882474e0297097075089c73 /src/libexpr/symbol-table.hh
parent3dcca18c30cbc09652f5ac644a9f8750f9ced0c9 (diff)
parent1c5f8bbfb5a5d55398823bb5d8a576a864cd1828 (diff)
Merge remote-tracking branch 'upstream/master' into from-dump-stream
Diffstat (limited to 'src/libexpr/symbol-table.hh')
-rw-r--r--src/libexpr/symbol-table.hh11
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);
}