mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
Avoid setting up unnecessary stack frames for function calls
This commit is contained in:
parent
8f1ba7f84c
commit
a74fb1e7e8
@ -88,12 +88,7 @@ public:
|
|||||||
|
|
||||||
static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Function::Ptr& func, const std::vector<Value>& arguments)
|
static inline Value FunctionCall(ScriptFrame& frame, const Value& self, const Function::Ptr& func, const std::vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<ScriptFrame> vframe;
|
ScriptFrame vframe = (self.IsEmpty()) ? ScriptFrame() : ScriptFrame(self);
|
||||||
|
|
||||||
if (!self.IsEmpty())
|
|
||||||
vframe = boost::make_shared<ScriptFrame>(self); /* passes self to the callee using a TLS variable */
|
|
||||||
else
|
|
||||||
vframe = boost::make_shared<ScriptFrame>();
|
|
||||||
|
|
||||||
return func->Invoke(arguments);
|
return func->Invoke(arguments);
|
||||||
}
|
}
|
||||||
@ -334,16 +329,15 @@ private:
|
|||||||
if (arguments.size() < funcargs.size())
|
if (arguments.size() < funcargs.size())
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Too few arguments for function"));
|
||||||
|
|
||||||
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
ScriptFrame *frame = ScriptFrame::GetCurrentFrame();
|
||||||
ScriptFrame frame(vframe->Self);
|
|
||||||
|
|
||||||
if (closedVars)
|
if (closedVars)
|
||||||
closedVars->CopyTo(frame.Locals);
|
closedVars->CopyTo(frame->Locals);
|
||||||
|
|
||||||
for (std::vector<Value>::size_type i = 0; i < std::min(arguments.size(), funcargs.size()); i++)
|
for (std::vector<Value>::size_type i = 0; i < std::min(arguments.size(), funcargs.size()); i++)
|
||||||
frame.Locals->Set(funcargs[i], arguments[i]);
|
frame->Locals->Set(funcargs[i], arguments[i]);
|
||||||
|
|
||||||
return expr->Evaluate(frame);
|
return expr->Evaluate(*frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Dictionary::Ptr EvaluateClosedVars(ScriptFrame& frame, std::map<String, Expression *> *closedVars)
|
static inline Dictionary::Ptr EvaluateClosedVars(ScriptFrame& frame, std::map<String, Expression *> *closedVars)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user