From d8ee0afda9c6947eb9477b7bfe0cec81628ef2fe Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 15 Jul 2020 20:51:55 +0100 Subject: refactor(3p/nix): Compare attribute sets by pointer equality Paired-With: Perry Lorier Change-Id: I418e9127c5d9d31559c59e461f17726ddbc051c4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1180 Tested-by: BuildkiteCI Reviewed-by: glittershark --- third_party/nix/src/libexpr/eval.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'third_party/nix') diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index 56e4006204..a834e097a5 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -1667,6 +1667,12 @@ bool EvalState::eqValues(Value& v1, Value& v2) { return true; case tAttrs: { + // As an optimisation if both values are pointing towards the + // same attribute set, we can skip all this extra work. + if (v1.attrs == v2.attrs) { + return true; + } + /* If both sets denote a derivation (type = "derivation"), then compare their outPaths. */ if (isDerivation(v1) && isDerivation(v2)) { -- cgit 1.4.1