CONTEXT: reduce malloc()s by replacing linked list with vector

This commit is contained in:
Alexander A. Klimov 2022-10-28 16:34:10 +02:00
parent f59f361f09
commit 70df0e298e
2 changed files with 8 additions and 8 deletions

View File

@ -6,22 +6,22 @@
using namespace icinga;
static boost::thread_specific_ptr<std::list<String> > l_Frames;
static boost::thread_specific_ptr<std::vector<String>> l_Frames;
ContextFrame::ContextFrame(const String& message)
{
GetFrames().push_front(message);
GetFrames().insert(GetFrames().begin(), message);
}
ContextFrame::~ContextFrame()
{
GetFrames().pop_front();
GetFrames().erase(GetFrames().begin());
}
std::list<String>& ContextFrame::GetFrames()
std::vector<String>& ContextFrame::GetFrames()
{
if (!l_Frames.get())
l_Frames.reset(new std::list<String>());
l_Frames.reset(new std::vector<String>());
return *l_Frames;
}

View File

@ -5,7 +5,7 @@
#include "base/i2-base.hpp"
#include "base/string.hpp"
#include <list>
#include <vector>
namespace icinga
{
@ -20,7 +20,7 @@ public:
size_t GetLength() const;
private:
std::list<String> m_Frames;
std::vector<String> m_Frames;
};
std::ostream& operator<<(std::ostream& stream, const ContextTrace& trace);
@ -37,7 +37,7 @@ public:
~ContextFrame();
private:
static std::list<String>& GetFrames();
static std::vector<String>& GetFrames();
friend class ContextTrace;
};