diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-04-08 21:33:38 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-06-10 16:21:28 +0200 |
commit | 3e60a922111c0868eb66bc5fac6ee3ef4a4dbb56 (patch) | |
tree | 53e02d50fdfe03a5413bf38a88bc39e1fa423e68 /src/common/Metric/Metric.cpp | |
parent | c669f5119c2fd66e28ba74db8b686248d27bd536 (diff) |
Core/Metric: Minor optimizations for metrics (reducing number of allocations)
(cherry picked from commit caaedbfa80870b10d58e124dd6bc6a637278da59)
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 56e7b8cdf17..3bb42ff8454 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -122,16 +122,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); } @@ -160,10 +160,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; } |