diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-10-28T12·50+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-10-28T12·50+0000 |
commit | 0c4828ea05798b9e070e233884739736115a830d (patch) | |
tree | 19b91ea1fac55bdd5e0a69fda73b74a6a13dcbed /src | |
parent | e11e6fb1c6709ca3f0e596a7b1fb988df2fbd9b1 (diff) |
* new(UseGC) is inexplicably slower than GC_MALLOC, so prefer the
latter.
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/eval.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index c36a679d350d..3ef17c36a287 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -259,7 +259,8 @@ void mkString(Value & v, const string & s, const PathSet & context) mkString(v, s.c_str()); if (!context.empty()) { unsigned int n = 0; - v.string.context = NEW const char *[context.size() + 1]; + v.string.context = (const char * *) + GC_MALLOC((context.size() + 1) * sizeof(char *)); foreach (PathSet::const_iterator, i, context) v.string.context[n++] = GC_STRDUP(i->c_str()); v.string.context[n] = 0; @@ -304,7 +305,7 @@ Value * EvalState::lookupVar(Env * env, const VarRef & var) Value * EvalState::allocValue() { nrValues++; - return NEW Value; + return (Value *) GC_MALLOC(sizeof(Value)); } @@ -313,7 +314,6 @@ Env & EvalState::allocEnv(unsigned int size) nrEnvs++; nrValuesInEnvs += size; Env * env = (Env *) GC_MALLOC(sizeof(Env) + size * sizeof(Value *)); - if (!env) throw std::bad_alloc(); /* Clear the values because maybeThunk() expects this. */ for (unsigned i = 0; i < size; ++i) @@ -335,7 +335,7 @@ void EvalState::mkList(Value & v, unsigned int length) { v.type = tList; v.list.length = length; - v.list.elems = NEW Value *[length]; + v.list.elems = (Value * *) GC_MALLOC(length * sizeof(Value *)); nrListElems += length; } |