diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-23T20·05+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-23T20·05+0200 |
commit | b83801f8b3b48f4d69414401c8a51724946a8666 (patch) | |
tree | 912be85806c1d0ebc49dfafc0431eca0ee928655 /src/nix-env/nix-env.cc | |
parent | 14be783676adbb3517b2f73fee31c6f341575440 (diff) |
Optimize small lists
The value pointers of lists with 1 or 2 elements are now stored in the list value itself. In particular, this makes the "concatMap (x: if cond then [(f x)] else [])" idiom cheaper.
Diffstat (limited to 'src/nix-env/nix-env.cc')
-rw-r--r-- | src/nix-env/nix-env.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 04f1016167a9..97a2bbdb7de0 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -1127,13 +1127,13 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) attrs2["type"] = "bool"; attrs2["value"] = v->boolean ? "true" : "false"; xml.writeEmptyElement("meta", attrs2); - } else if (v->type == tList) { + } else if (v->isList()) { attrs2["type"] = "strings"; XMLOpenElement m(xml, "meta", attrs2); - for (unsigned int j = 0; j < v->list.length; ++j) { - if (v->list.elems[j]->type != tString) continue; + for (unsigned int j = 0; j < v->listSize(); ++j) { + if (v->listElems()[j]->type != tString) continue; XMLAttrs attrs3; - attrs3["value"] = v->list.elems[j]->string.s; + attrs3["value"] = v->listElems()[j]->string.s; xml.writeEmptyElement("string", attrs3); } } |