From 242f9bf3dc04170502020fb0338b78ea76b9ebac Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 30 Sep 2021 21:31:21 +0000 Subject: `std::visit` by reference I had started the trend of doing `std::visit` by value (because a type error once mislead me into thinking that was the only form that existed). While the optomizer in principle should be able to deal with extra coppying or extra indirection once the lambdas inlined, sticking with by reference is the conventional default. I hope this might even improve performance. --- src/libstore/misc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstore/misc.cc') diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index b4929b445..f184dd857 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -166,7 +166,7 @@ void Store::queryMissing(const std::vector & targets, } std::visit(overloaded { - [&](DerivedPath::Built bfd) { + [&](const DerivedPath::Built & bfd) { if (!isValidPath(bfd.drvPath)) { // FIXME: we could try to substitute the derivation. auto state(state_.lock()); @@ -199,7 +199,7 @@ void Store::queryMissing(const std::vector & targets, mustBuildDrv(bfd.drvPath, *drv); }, - [&](DerivedPath::Opaque bo) { + [&](const DerivedPath::Opaque & bo) { if (isValidPath(bo.path)) return; -- cgit v1.2.3