@@ -399,18 +399,19 @@ ExprAttrs::bindInheritSources(EvalState & es, const std::shared_ptr<const Static
399399 return inner;
400400}
401401
402+ void ExprAttrs::moveDataToAllocator (std::pmr::polymorphic_allocator<char > & alloc)
403+ {
404+ AttrDefs newAttrs{std::move (*attrs), alloc};
405+ attrs.emplace (std::move (newAttrs), alloc);
406+ DynamicAttrDefs newDynamicAttrs{std::move (*dynamicAttrs), alloc};
407+ dynamicAttrs.emplace (std::move (newDynamicAttrs), alloc);
408+ if (inheritFromExprs)
409+ inheritFromExprs = std::make_unique<std::pmr::vector<Expr *>>(std::move (*inheritFromExprs), alloc);
410+ }
411+
402412void ExprAttrs::bindVars (EvalState & es, const std::shared_ptr<const StaticEnv> & env)
403413{
404- // Move storage into the Exprs arena
405- {
406- auto arena = es.mem .exprs .alloc ;
407- AttrDefs newAttrs{std::move (*attrs), arena};
408- attrs.emplace (std::move (newAttrs), arena);
409- DynamicAttrDefs newDynamicAttrs{std::move (*dynamicAttrs), arena};
410- dynamicAttrs.emplace (std::move (newDynamicAttrs), arena);
411- if (inheritFromExprs)
412- inheritFromExprs = std::make_unique<std::pmr::vector<Expr *>>(std::move (*inheritFromExprs), arena);
413- }
414+ moveDataToAllocator (es.mem .exprs .alloc );
414415
415416 if (es.debugRepl )
416417 es.exprEnvs .insert (std::make_pair (this , env));
@@ -484,14 +485,15 @@ void ExprLambda::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv>
484485 body->bindVars (es, newEnv);
485486}
486487
488+ void ExprCall::moveDataToAllocator (std::pmr::polymorphic_allocator<char > & alloc)
489+ {
490+ std::pmr::vector<Expr *> newArgs{std::move (*args), alloc};
491+ args.emplace (std::move (newArgs), alloc);
492+ }
493+
487494void ExprCall::bindVars (EvalState & es, const std::shared_ptr<const StaticEnv> & env)
488495{
489- // Move storage into the Exprs arena
490- {
491- auto arena = es.mem .exprs .alloc ;
492- std::pmr::vector<Expr *> newArgs{std::move (*args), arena};
493- args.emplace (std::move (newArgs), arena);
494- }
496+ moveDataToAllocator (es.mem .exprs .alloc );
495497 if (es.debugRepl )
496498 es.exprEnvs .insert (std::make_pair (this , env));
497499
@@ -502,6 +504,7 @@ void ExprCall::bindVars(EvalState & es, const std::shared_ptr<const StaticEnv> &
502504
503505void ExprLet::bindVars (EvalState & es, const std::shared_ptr<const StaticEnv> & env)
504506{
507+ attrs->moveDataToAllocator (es.mem .exprs .alloc );
505508 auto newEnv = [&]() -> std::shared_ptr<const StaticEnv> {
506509 auto newEnv = std::make_shared<StaticEnv>(nullptr , env, attrs->attrs ->size ());
507510
0 commit comments