aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/misc.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-10-09 15:51:52 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-10-09 16:06:29 +0200
commit99b73fb5071db9fd757c9927fc3fde34e2abac63 (patch)
treefb50f681aced9f566da52aaf22eb4275471d010a /src/libstore/misc.cc
parente6e61f0a54dac0174df996e93fcfedcac7769ab4 (diff)
OCD performance fix: {find,count}+insert => insert
Diffstat (limited to 'src/libstore/misc.cc')
-rw-r--r--src/libstore/misc.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index dddf13430..05b93d4c9 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -29,8 +29,7 @@ void Store::computeFSClosure(const PathSet & startPaths,
{
auto state(state_.lock());
if (state->exc) return;
- if (state->paths.count(path)) return;
- state->paths.insert(path);
+ if (!state->paths.insert(path).second) return;
state->pending++;
}
@@ -175,8 +174,7 @@ void Store::queryMissing(const PathSet & targets,
{
auto state(state_.lock());
- if (state->done.count(path)) return;
- state->done.insert(path);
+ if (!state->done.insert(path).second) return;
}
DrvPathWithOutputs i2 = parseDrvPathWithOutputs(path);
@@ -252,8 +250,7 @@ Paths Store::topoSortPaths(const PathSet & paths)
if (parents.find(path) != parents.end())
throw BuildError(format("cycle detected in the references of '%1%' from '%2%'") % path % *parent);
- if (visited.find(path) != visited.end()) return;
- visited.insert(path);
+ if (!visited.insert(path).second) return;
parents.insert(path);
PathSet references;