about summary refs log tree commit diff
path: root/third_party/nix/src/nix-env/nix-env.cc
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-07-18T15·40+0100
committertazjin <mail@tazj.in>2020-07-18T18·08+0000
commitcdc1a0bb6ec52cd05c1a72c00c3c3a4f716a429a (patch)
tree678d1c8586bc82a3476e581b1cca6810d072e115 /third_party/nix/src/nix-env/nix-env.cc
parent56614c75e4a187c34706af718d9d8d69685c41b2 (diff)
refactor(3p/nix/libexpr): Back Nix lists with std::vector r/1377
This change does away with the previous special-casing of lists of
certain element sizes, and the use of raw C-style arrays.

Lists are now backed by a std::vector of nix::Value*, which uses the
traceable GC allocator.

This change is unfortunately quite noisy because the accessor methods
were updated/removed accordingly, so all callsites of Nix-related
lists have changed.

For some operations in primops.cc where keeping the previous code
structure would have been more difficult with a "proper" vector, the
implementation has been replaced with std::vector methods. For
example, list concatenation now uses appropriate range inserts.

Anecdotally the performance of this is about equal, to even slightly
better, than the previous implementation.

All language tests pass and the depot paths I've used for testing
still evaluate.

Change-Id: Ib5eca6c0207429cb323a330c838c3a2200b2c693
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1266
Tested-by: BuildkiteCI
Reviewed-by: isomer <isomer@tvl.fyi>
Reviewed-by: Kane York <rikingcoding@gmail.com>
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix/src/nix-env/nix-env.cc')
-rw-r--r--third_party/nix/src/nix-env/nix-env.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/third_party/nix/src/nix-env/nix-env.cc b/third_party/nix/src/nix-env/nix-env.cc
index 10e2e9492e..07bcb54eb6 100644
--- a/third_party/nix/src/nix-env/nix-env.cc
+++ b/third_party/nix/src/nix-env/nix-env.cc
@@ -158,8 +158,7 @@ static void loadSourceExpr(EvalState& state, const Path& path, Value& v) {
      directory). */
   else if (S_ISDIR(st.st_mode)) {
     state.mkAttrs(v, 1024);
-    state.mkList(*state.allocAttr(v, state.symbols.Create("_combineChannels")),
-                 0);
+    state.mkList(*state.allocAttr(v, state.symbols.Create("_combineChannels")));
     StringSet attrs;
     getAllExprs(state, path, attrs, v);
   }
@@ -1199,11 +1198,11 @@ static void opQuery(Globals& globals, Strings opFlags, Strings opArgs) {
                   attrs2["type"] = "strings";
                   XMLOpenElement m(xml, "meta", attrs2);
                   for (unsigned int j = 0; j < v->listSize(); ++j) {
-                    if (v->listElems()[j]->type != tString) {
+                    if ((*v->list)[j]->type != tString) {
                       continue;
                     }
                     XMLAttrs attrs3;
-                    attrs3["value"] = v->listElems()[j]->string.s;
+                    attrs3["value"] = (*v->list)[j]->string.s;
                     xml.writeEmptyElement("string", attrs3);
                   }
                 } else if (v->type == tAttrs) {