diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-29 13:28:14 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-11-29 13:28:14 +0200 |
commit | bd90dfbbbca15500b826eb9a4bb6959aedbe28f7 (patch) | |
tree | 2fee716cf636e7e50797eb07b23e5f0eb17f8f4b /libbuild2/script/regex.cxx | |
parent | ea1a4a3c8b7551a59667889edc35f806fd2ce45a (diff) |
Use list instead of unordered_set in regex line_pool
Diffstat (limited to 'libbuild2/script/regex.cxx')
-rw-r--r-- | libbuild2/script/regex.cxx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libbuild2/script/regex.cxx b/libbuild2/script/regex.cxx index 3f796b6..11ff8a1 100644 --- a/libbuild2/script/regex.cxx +++ b/libbuild2/script/regex.cxx @@ -75,15 +75,29 @@ namespace build2 string::traits_type::find (ex, 4, c) != nullptr))); } + template <typename S> + static inline const char_string* + find_or_insert (line_pool& p, S&& s) + { + auto i (find (p.strings.begin (), p.strings.end (), s)); + if (i == p.strings.end ()) + { + p.strings.push_front (forward<S> (s)); + i = p.strings.begin (); + } + + return &*i; + } + line_char:: line_char (const char_string& s, line_pool& p) - : line_char (&(*p.strings.emplace (s).first)) + : line_char (find_or_insert (p, s)) { } line_char:: line_char (char_string&& s, line_pool& p) - : line_char (&(*p.strings.emplace (move (s)).first)) + : line_char (find_or_insert (p, move (s))) { } |