forked from lix-project/lix
* Huge reduction in memory use (2/3 or so on large nix-env -qas
operations): share ATermMaps between DrvInfos.
This commit is contained in:
parent
11ae2d1e7a
commit
b52e711910
|
@ -5,7 +5,7 @@
|
||||||
string DrvInfo::queryDrvPath(EvalState & state) const
|
string DrvInfo::queryDrvPath(EvalState & state) const
|
||||||
{
|
{
|
||||||
if (drvPath == "") {
|
if (drvPath == "") {
|
||||||
Expr a = attrs.get("drvPath");
|
Expr a = attrs->get("drvPath");
|
||||||
(string &) drvPath = a ? evalPath(state, a) : "";
|
(string &) drvPath = a ? evalPath(state, a) : "";
|
||||||
}
|
}
|
||||||
return drvPath;
|
return drvPath;
|
||||||
|
@ -15,7 +15,7 @@ string DrvInfo::queryDrvPath(EvalState & state) const
|
||||||
string DrvInfo::queryOutPath(EvalState & state) const
|
string DrvInfo::queryOutPath(EvalState & state) const
|
||||||
{
|
{
|
||||||
if (outPath == "") {
|
if (outPath == "") {
|
||||||
Expr a = attrs.get("outPath");
|
Expr a = attrs->get("outPath");
|
||||||
if (!a) throw Error("output path missing");
|
if (!a) throw Error("output path missing");
|
||||||
(string &) outPath = evalPath(state, a);
|
(string &) outPath = evalPath(state, a);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
|
||||||
{
|
{
|
||||||
MetaInfo meta;
|
MetaInfo meta;
|
||||||
|
|
||||||
Expr a = attrs.get("meta");
|
Expr a = attrs->get("meta");
|
||||||
if (!a) return meta; /* fine, empty meta information */
|
if (!a) return meta; /* fine, empty meta information */
|
||||||
|
|
||||||
ATermMap attrs2;
|
ATermMap attrs2;
|
||||||
|
@ -66,10 +66,10 @@ static bool getDerivation(EvalState & state, Expr e,
|
||||||
e = evalExpr(state, e);
|
e = evalExpr(state, e);
|
||||||
if (!matchAttrs(e, es)) return true;
|
if (!matchAttrs(e, es)) return true;
|
||||||
|
|
||||||
ATermMap attrs;
|
shared_ptr<ATermMap> attrs(new ATermMap());
|
||||||
queryAllAttrs(e, attrs, false);
|
queryAllAttrs(e, *attrs, false);
|
||||||
|
|
||||||
Expr a = attrs.get("type");
|
Expr a = attrs->get("type");
|
||||||
if (!a || evalString(state, a) != "derivation") return true;
|
if (!a || evalString(state, a) != "derivation") return true;
|
||||||
|
|
||||||
/* Remove spurious duplicates (e.g., an attribute set like
|
/* Remove spurious duplicates (e.g., an attribute set like
|
||||||
|
@ -79,11 +79,11 @@ static bool getDerivation(EvalState & state, Expr e,
|
||||||
|
|
||||||
DrvInfo drv;
|
DrvInfo drv;
|
||||||
|
|
||||||
a = attrs.get("name");
|
a = attrs->get("name");
|
||||||
if (!a) throw badTerm("derivation name missing", e);
|
if (!a) throw badTerm("derivation name missing", e);
|
||||||
drv.name = evalString(state, a);
|
drv.name = evalString(state, a);
|
||||||
|
|
||||||
a = attrs.get("system");
|
a = attrs->get("system");
|
||||||
if (!a)
|
if (!a)
|
||||||
drv.system = "unknown";
|
drv.system = "unknown";
|
||||||
else
|
else
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ public:
|
||||||
string name;
|
string name;
|
||||||
string system;
|
string system;
|
||||||
|
|
||||||
ATermMap attrs;
|
shared_ptr<ATermMap> attrs;
|
||||||
|
|
||||||
string queryDrvPath(EvalState & state) const;
|
string queryDrvPath(EvalState & state) const;
|
||||||
string queryOutPath(EvalState & state) const;
|
string queryOutPath(EvalState & state) const;
|
||||||
|
|
|
@ -348,6 +348,7 @@ static void queryInstSources(EvalState & state,
|
||||||
assertStorePath(*i);
|
assertStorePath(*i);
|
||||||
|
|
||||||
DrvInfo elem;
|
DrvInfo elem;
|
||||||
|
elem.attrs = shared_ptr<ATermMap>(new ATermMap()); /* ugh... */
|
||||||
string name = baseNameOf(*i);
|
string name = baseNameOf(*i);
|
||||||
unsigned int dash = name.find('-');
|
unsigned int dash = name.find('-');
|
||||||
if (dash != string::npos)
|
if (dash != string::npos)
|
||||||
|
|
Loading…
Reference in a new issue