mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-08 06:14:28 +02:00
CONTEXT: reduce malloc()s by replacing linked list with vector
This commit is contained in:
parent
f59f361f09
commit
70df0e298e
@ -6,22 +6,22 @@
|
|||||||
|
|
||||||
using namespace icinga;
|
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)
|
ContextFrame::ContextFrame(const String& message)
|
||||||
{
|
{
|
||||||
GetFrames().push_front(message);
|
GetFrames().insert(GetFrames().begin(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextFrame::~ContextFrame()
|
ContextFrame::~ContextFrame()
|
||||||
{
|
{
|
||||||
GetFrames().pop_front();
|
GetFrames().erase(GetFrames().begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<String>& ContextFrame::GetFrames()
|
std::vector<String>& ContextFrame::GetFrames()
|
||||||
{
|
{
|
||||||
if (!l_Frames.get())
|
if (!l_Frames.get())
|
||||||
l_Frames.reset(new std::list<String>());
|
l_Frames.reset(new std::vector<String>());
|
||||||
|
|
||||||
return *l_Frames;
|
return *l_Frames;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "base/i2-base.hpp"
|
#include "base/i2-base.hpp"
|
||||||
#include "base/string.hpp"
|
#include "base/string.hpp"
|
||||||
#include <list>
|
#include <vector>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ public:
|
|||||||
size_t GetLength() const;
|
size_t GetLength() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<String> m_Frames;
|
std::vector<String> m_Frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& stream, const ContextTrace& trace);
|
std::ostream& operator<<(std::ostream& stream, const ContextTrace& trace);
|
||||||
@ -37,7 +37,7 @@ public:
|
|||||||
~ContextFrame();
|
~ContextFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::list<String>& GetFrames();
|
static std::vector<String>& GetFrames();
|
||||||
|
|
||||||
friend class ContextTrace;
|
friend class ContextTrace;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user