forked from lix-project/lix
* Improve sharing a bit.
This commit is contained in:
parent
497e4ad126
commit
8ca4a001cb
|
@ -652,12 +652,15 @@ void ExprWith::eval(EvalState & state, Env & env, Value & v)
|
||||||
/* Because the first `with' may be a shallow copy of another
|
/* Because the first `with' may be a shallow copy of another
|
||||||
attribute set (through a tCopy node), we need to clone its
|
attribute set (through a tCopy node), we need to clone its
|
||||||
`attrs' before modifying them. */
|
`attrs' before modifying them. */
|
||||||
env2.values[0].attrs = new Bindings(*env2.values[0].attrs);
|
Bindings * old(env2.values[0].attrs);
|
||||||
|
state.mkAttrs(env2.values[0]);
|
||||||
|
foreach (Bindings::iterator, i, *old)
|
||||||
|
mkCopy((*env2.values[0].attrs)[i->first], i->second);
|
||||||
|
|
||||||
foreach (Bindings::iterator, i, *env3->values[0].attrs) {
|
foreach (Bindings::iterator, i, *env3->values[0].attrs) {
|
||||||
Bindings::iterator j = env2.values[0].attrs->find(i->first);
|
Bindings::iterator j = env2.values[0].attrs->find(i->first);
|
||||||
if (j == env2.values[0].attrs->end())
|
if (j == env2.values[0].attrs->end())
|
||||||
(*env2.values[0].attrs)[i->first] = i->second; // !!! sharing
|
mkCopy((*env2.values[0].attrs)[i->first], i->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +734,7 @@ void ExprOpUpdate::eval(EvalState & state, Env & env, Value & v)
|
||||||
state.forceAttrs(v2);
|
state.forceAttrs(v2);
|
||||||
|
|
||||||
foreach (Bindings::iterator, i, *v2.attrs)
|
foreach (Bindings::iterator, i, *v2.attrs)
|
||||||
(*v.attrs)[i->first] = i->second; // !!! sharing
|
mkCopy((*v.attrs)[i->first], i->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -733,7 +733,7 @@ static void prim_listToAttrs(EvalState & state, Value * * args, Value & v)
|
||||||
if (j == v2.attrs->end())
|
if (j == v2.attrs->end())
|
||||||
throw TypeError("`value' attribute missing in a call to `listToAttrs'");
|
throw TypeError("`value' attribute missing in a call to `listToAttrs'");
|
||||||
|
|
||||||
(*v.attrs)[state.symbols.create(name)] = j->second; // !!! sharing?
|
mkCopy((*v.attrs)[state.symbols.create(name)], j->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue