This commit is contained in:
Alexander Aleksandrovič Klimov 2026-05-21 15:54:51 +00:00 committed by GitHub
commit fdbc7f3690
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 14 deletions

View file

@ -10,7 +10,7 @@
using namespace icinga;
boost::thread_specific_ptr<std::stack<ScriptFrame *> > ScriptFrame::m_ScriptFrames;
boost::thread_specific_ptr<std::vector<ScriptFrame*>> ScriptFrame::m_ScriptFrames;
static Namespace::Ptr l_SystemNS, l_StatsNS;
@ -69,10 +69,10 @@ ScriptFrame::ScriptFrame(bool allocLocals, Value self)
void ScriptFrame::InitializeFrame()
{
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
auto frames (m_ScriptFrames.get());
if (frames && !frames->empty()) {
ScriptFrame *frame = frames->top();
ScriptFrame *frame = frames->back();
// See the documentation of `ScriptFrame::Globals` for why these two are inherited and Globals isn't.
PermChecker = frame->PermChecker;
@ -142,37 +142,37 @@ void ScriptFrame::DecreaseStackDepth()
ScriptFrame *ScriptFrame::GetCurrentFrame()
{
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
auto frames (m_ScriptFrames.get());
ASSERT(!frames->empty());
return frames->top();
return frames->back();
}
ScriptFrame *ScriptFrame::PopFrame()
{
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
auto frames (m_ScriptFrames.get());
ASSERT(!frames->empty());
ScriptFrame *frame = frames->top();
frames->pop();
ScriptFrame *frame = frames->back();
frames->pop_back();
return frame;
}
void ScriptFrame::PushFrame(ScriptFrame *frame)
{
std::stack<ScriptFrame *> *frames = m_ScriptFrames.get();
auto frames (m_ScriptFrames.get());
if (!frames) {
frames = new std::stack<ScriptFrame *>();
frames = new std::vector<ScriptFrame*>();
m_ScriptFrames.reset(frames);
}
if (!frames->empty()) {
ScriptFrame *parent = frames->top();
ScriptFrame *parent = frames->back();
frame->Depth += parent->Depth;
}
frames->push(frame);
frames->emplace_back(frame);
}

View file

@ -9,7 +9,7 @@
#include "base/namespace.hpp"
#include "base/scriptpermission.hpp"
#include <boost/thread/tss.hpp>
#include <stack>
#include <vector>
namespace icinga
{
@ -55,7 +55,7 @@ private:
*/
Namespace::Ptr Globals;
static boost::thread_specific_ptr<std::stack<ScriptFrame *> > m_ScriptFrames;
static boost::thread_specific_ptr<std::vector<ScriptFrame*>> m_ScriptFrames;
static void PushFrame(ScriptFrame *frame);
static ScriptFrame *PopFrame();