1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

* Use a symbol table to represent identifiers and attribute names

efficiently.  The symbol table ensures that there is only one copy
  of each symbol, thus allowing symbols to be compared efficiently
  using a pointer equality test.
This commit is contained in:
Eelco Dolstra 2010-04-13 12:25:42 +00:00
parent 10e8b1fd15
commit ac1e8f40d4
15 changed files with 228 additions and 101 deletions

View file

@ -28,7 +28,7 @@ static void showAttrs(EvalState & state, bool strict, Bindings & attrs,
names.insert(i->first);
foreach (StringSet::iterator, i, names) {
XMLOpenElement _(doc, "attr", singletonAttrs("name", *i));
printValueAsXML(state, strict, attrs[*i], doc, context, drvsSeen);
printValueAsXML(state, strict, attrs[state.symbols.create(*i)], doc, context, drvsSeen);
}
}
@ -67,14 +67,14 @@ static void printValueAsXML(EvalState & state, bool strict, Value & v,
if (state.isDerivation(v)) {
XMLAttrs xmlAttrs;
Bindings::iterator a = v.attrs->find("derivation");
Bindings::iterator a = v.attrs->find(state.symbols.create("derivation"));
Path drvPath;
a = v.attrs->find("drvPath");
a = v.attrs->find(state.sDrvPath);
if (a != v.attrs->end() && a->second.type == tString)
xmlAttrs["drvPath"] = drvPath = a->second.string.s;
a = v.attrs->find("outPath");
a = v.attrs->find(state.sOutPath);
if (a != v.attrs->end() && a->second.type == tString)
xmlAttrs["outPath"] = a->second.string.s;