diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-04-08 21:33:38 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-04-08 21:33:38 +0200 |
commit | caaedbfa80870b10d58e124dd6bc6a637278da59 (patch) | |
tree | 7822f9fc1406ddb19560879a69017321c12e7712 /src/common/Metric/Metric.cpp | |
parent | 82246c0a061a5ffb2b364ebe3b2775fd15c24e48 (diff) |
Core/Metric: Minor optimizations for metrics (reducing number of allocations)
Diffstat (limited to 'src/common/Metric/Metric.cpp')
-rw-r--r-- | src/common/Metric/Metric.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index 97d68568a3f..9516db84d48 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -123,16 +123,16 @@ bool Metric::ShouldLog(std::string const& category, int64 value) const return value >= threshold->second; } -void Metric::LogEvent(std::string const& category, std::string const& title, std::string const& description) +void Metric::LogEvent(std::string category, std::string title, std::string description) { using namespace std::chrono; MetricData* data = new MetricData; - data->Category = category; + data->Category = std::move(category); data->Timestamp = system_clock::now(); data->Type = METRIC_DATA_EVENT; - data->Title = title; - data->Text = description; + data->Title = std::move(title); + data->ValueOrEventText = std::move(description); _queuedData.Enqueue(data); } @@ -161,10 +161,10 @@ void Metric::SendBatch() switch (data->Type) { case METRIC_DATA_VALUE: - batchedData << "value=" << data->Value; + batchedData << "value=" << data->ValueOrEventText; break; case METRIC_DATA_EVENT: - batchedData << "title=\"" << data->Title << "\",text=\"" << data->Text << "\""; + batchedData << "title=\"" << data->Title << "\",text=\"" << data->ValueOrEventText << "\""; break; } |