aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-12-27 16:56:25 +0100
committerGitHub <noreply@github.com>2021-12-27 16:56:25 +0100
commit0e90b13ab1df925e549b5d55853b65911b4b40d3 (patch)
tree5ead59578dee00cde7b503a31d537757546c0511 /src/libexpr
parentaf553b20902b8b8efbccab5f880879b09e95eb32 (diff)
parenta4ab0a74d97c7c31df69f04870fa56cde89701a3 (diff)
Merge pull request #5835 from yorickvP/fast-repl-load
Fix accidental O(n^2 * log n) performance in NixRepl::addAttrsToScope
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/nixexpr.hh7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index c013f5deb..b328b3941 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -368,6 +368,13 @@ struct StaticEnv
[](const Vars::value_type & a, const Vars::value_type & b) { return a.first < b.first; });
}
+ void deduplicate()
+ {
+ const auto last = std::unique(vars.begin(), vars.end(),
+ [] (const Vars::value_type & a, const Vars::value_type & b) { return a.first == b.first; });
+ vars.erase(last, vars.end());
+ }
+
Vars::const_iterator find(const Symbol & name) const
{
Vars::value_type key(name, 0);