From 5b58991a71d15123c010bbbd7f08530dbc31173f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 19 Sep 2014 16:49:41 +0200 Subject: Store Attrs inside Bindings This prevents a double allocation per attribute set. --- src/nix-env/nix-env.cc | 14 +++++++------- src/nix-env/user-env.cc | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nix-env') diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 5116d955fe09..c24165da8f1d 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -44,7 +44,7 @@ struct InstallSourceInfo Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */ Path profile; /* for srcProfile */ string systemFilter; /* for srcNixExprDrvs */ - Bindings autoArgs; + Bindings * autoArgs; }; @@ -350,7 +350,7 @@ static void queryInstSources(EvalState & state, Nix expression. */ DrvInfos allElems; loadDerivations(state, instSource.nixExprPath, - instSource.systemFilter, instSource.autoArgs, "", allElems); + instSource.systemFilter, *instSource.autoArgs, "", allElems); elems = filterBySelector(state, allElems, args, newestOnly); @@ -373,7 +373,7 @@ static void queryInstSources(EvalState & state, Value vFun, vTmp; state.eval(eFun, vFun); mkApp(vTmp, vFun, vArg); - getDerivations(state, vTmp, "", instSource.autoArgs, elems, true); + getDerivations(state, vTmp, "", *instSource.autoArgs, elems, true); } break; @@ -423,8 +423,8 @@ static void queryInstSources(EvalState & state, Value vRoot; loadSourceExpr(state, instSource.nixExprPath, vRoot); foreach (Strings::const_iterator, i, args) { - Value & v(*findAlongAttrPath(state, *i, instSource.autoArgs, vRoot)); - getDerivations(state, v, "", instSource.autoArgs, elems, true); + Value & v(*findAlongAttrPath(state, *i, *instSource.autoArgs, vRoot)); + getDerivations(state, v, "", *instSource.autoArgs, elems, true); } break; } @@ -926,7 +926,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) if (source == sAvailable || compareVersions) loadDerivations(*globals.state, globals.instSource.nixExprPath, - globals.instSource.systemFilter, globals.instSource.autoArgs, + globals.instSource.systemFilter, *globals.instSource.autoArgs, attrPath, availElems); DrvInfos elems_ = filterBySelector(*globals.state, @@ -1423,7 +1423,7 @@ int main(int argc, char * * argv) if (file != "") globals.instSource.nixExprPath = lookupFileArg(*globals.state, file); - evalAutoArgs(*globals.state, autoArgs_, globals.instSource.autoArgs); + globals.instSource.autoArgs = evalAutoArgs(*globals.state, autoArgs_); if (globals.profile == "") globals.profile = getEnv("NIX_PROFILE", ""); diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc index 3ebd6c1f2362..3bc31b9eafeb 100644 --- a/src/nix-env/user-env.cc +++ b/src/nix-env/user-env.cc @@ -19,7 +19,7 @@ DrvInfos queryInstalled(EvalState & state, const Path & userEnv) if (pathExists(manifestFile)) { Value v; state.evalFile(manifestFile, v); - Bindings bindings; + Bindings & bindings(*state.allocBindings(0)); getDerivations(state, v, "", bindings, elems, false); } return elems; -- cgit 1.4.1