Core/Misc: Remove boost::container::small_vector from header files

This commit is contained in:
Shauren
2023-01-06 16:54:43 +01:00
parent e8e330addd
commit 280d83ecc7
2 changed files with 25 additions and 8 deletions

View File

@@ -152,8 +152,14 @@ void Metric::SendBatch()
if (!_realmName.empty())
batchedData << ",realm=" << _realmName;
for (MetricTag const& tag : data->Tags)
batchedData << "," << tag.first << "=" << FormatInfluxDBTagValue(tag.second);
if (data->Tags)
{
auto begin = std::visit([](auto&& value) { return value.data(); }, *data->Tags);
auto end = std::visit([](auto&& value) { return value.data() + value.size(); }, *data->Tags);
for (auto itr = begin; itr != end; ++itr)
if (!itr->first.empty())
batchedData << "," << itr->first << "=" << FormatInfluxDBTagValue(itr->second);
}
batchedData << " ";

View File

@@ -22,13 +22,13 @@
#include "Duration.h"
#include "MPSCQueue.h"
#include "Optional.h"
#include <boost/container/small_vector.hpp>
#include <functional>
#include <iosfwd>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <variant>
namespace Trinity
{
@@ -46,7 +46,6 @@ enum MetricDataType
};
using MetricTag = std::pair<std::string, std::string>;
using MetricTagsVector = boost::container::small_vector<MetricTag, 2>;
struct MetricData
{
@@ -55,7 +54,7 @@ struct MetricData
MetricDataType Type;
// LogValue-specific fields
MetricTagsVector Tags;
Optional<std::variant<std::array<MetricTag, 2>, std::vector<MetricTag>>> Tags;
// LogEvent-specific fields
std::string Title;
@@ -113,8 +112,8 @@ public:
void Update();
bool ShouldLog(std::string const& category, int64 value) const;
template<class T, class... Tags>
void LogValue(std::string category, T value, Tags&&... tags)
template<class T, class... TagsList>
void LogValue(std::string category, T value, TagsList&&... tags)
{
using namespace std::chrono;
@@ -124,7 +123,19 @@ public:
data->Type = METRIC_DATA_VALUE;
data->ValueOrEventText = FormatInfluxDBValue(value);
if constexpr (sizeof...(tags) > 0)
(data->Tags.emplace_back(std::move(tags)), ...);
{
data->Tags.emplace();
if constexpr (sizeof...(tags) > 2)
{
decltype(auto) tagsVector = data->Tags->emplace<1>();
(tagsVector.emplace_back(std::move(tags)), ...);
}
else
{
decltype(auto) tagsArray = data->Tags->emplace<0>();
tagsArray = { std::move(tags)... };
}
}
_queuedData.Enqueue(data);
}