aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc22
-rw-r--r--src/libexpr/eval.hh1
-rw-r--r--src/libexpr/primops.cc23
3 files changed, 12 insertions, 34 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 3f2371d79..faf18cb7f 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -282,13 +282,6 @@ Value * EvalState::allocValue()
}
-Value * EvalState::allocValues(unsigned int count)
-{
- nrValues += count;
- return (Value *) GC_MALLOC(count * sizeof(Value));
-}
-
-
Env & EvalState::allocEnv(unsigned int size)
{
nrEnvs++;
@@ -542,11 +535,8 @@ void ExprLet::eval(EvalState & state, Env & env, Value & v)
void ExprList::eval(EvalState & state, Env & env, Value & v)
{
state.mkList(v, elems.size());
- Value * vs = state.allocValues(v.list.length);
- for (unsigned int n = 0; n < v.list.length; ++n) {
- v.list.elems[n] = &vs[n];
- mkThunk(vs[n], env, elems[n]);
- }
+ for (unsigned int n = 0; n < v.list.length; ++n)
+ mkThunk(*(v.list.elems[n] = state.allocValue()), env, elems[n]);
}
@@ -630,12 +620,10 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v)
throw;
}
} else {
- Value * v2 = allocValues(2);
- v2[0] = fun;
- v2[1] = arg;
v.type = tPrimOpApp;
- v.primOpApp.left = &v2[0];
- v.primOpApp.right = &v2[1];
+ v.primOpApp.left = allocValue();
+ *v.primOpApp.left = fun;
+ v.primOpApp.right = &arg;
v.primOpApp.argsLeft = argsLeft - 1;
}
return;
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index b6ec927f0..5f5966930 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -290,7 +290,6 @@ public:
/* Allocation primitives. */
Value * allocValue();
- Value * allocValues(unsigned int count);
Env & allocEnv(unsigned int size);
Value * allocAttr(Value & vAttrs, const Symbol & name);
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index c7709ca9e..01cbf7a7c 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -167,13 +167,9 @@ static void prim_genericClosure(EvalState & state, Value * * args, Value & v)
/* Create the result list. */
state.mkList(v, res.size());
- Value * vs = state.allocValues(res.size());
-
unsigned int n = 0;
- foreach (list<Value>::iterator, i, res) {
- v.list.elems[n] = &vs[n];
- vs[n++] = *i;
- }
+ foreach (list<Value>::iterator, i, res)
+ *(v.list.elems[n++] = state.allocValue()) = *i;
}
@@ -691,17 +687,14 @@ static void prim_attrNames(EvalState & state, Value * * args, Value & v)
state.forceAttrs(*args[0]);
state.mkList(v, args[0]->attrs->size());
- Value * vs = state.allocValues(v.list.length);
StringSet names;
foreach (Bindings::iterator, i, *args[0]->attrs)
names.insert(i->first);
unsigned int n = 0;
- foreach (StringSet::iterator, i, names) {
- v.list.elems[n] = &vs[n];
- mkString(vs[n++], *i);
- }
+ foreach (StringSet::iterator, i, names)
+ mkString(*(v.list.elems[n++] = state.allocValue()), *i);
}
@@ -870,12 +863,10 @@ static void prim_map(EvalState & state, Value * * args, Value & v)
state.forceList(*args[1]);
state.mkList(v, args[1]->list.length);
- Value * vs = state.allocValues(v.list.length);
- for (unsigned int n = 0; n < v.list.length; ++n) {
- v.list.elems[n] = &vs[n];
- mkApp(vs[n], *args[0], *args[1]->list.elems[n]);
- }
+ for (unsigned int n = 0; n < v.list.length; ++n)
+ mkApp(*(v.list.elems[n] = state.allocValue()),
+ *args[0], *args[1]->list.elems[n]);
}