diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-02-06 13:17:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-06 13:17:58 +0100 |
commit | 93293fc66b3c9130904eb274834f617b3fb2c1a9 (patch) | |
tree | e47f9ae8e12d2d1de60422437911a74170ec0925 /src/libexpr | |
parent | 9148be6bfc6c9f239a92afdcde6b8a854d55b54d (diff) | |
parent | 1daf1babf956cab98857db92de8829a1e7f2ae3e (diff) |
Merge pull request #6042 from pennae/fix-repl-a
fix nix repl not overriding existing bindings in :a
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/nixexpr.hh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index 4e923ac89..6f6acb074 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -367,15 +367,19 @@ struct StaticEnv void sort() { - std::sort(vars.begin(), vars.end(), + std::stable_sort(vars.begin(), vars.end(), [](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()); + auto it = vars.begin(), jt = it, end = vars.end(); + while (jt != end) { + *it = *jt++; + while (jt != end && it->first == jt->first) *it = *jt++; + it++; + } + vars.erase(it, end); } Vars::const_iterator find(const Symbol & name) const |