From: Gunnar Beutner Date: Mon, 2 Dec 2013 11:55:35 +0000 (+0100) Subject: Avoid temporary String objects in PerfdataValue::Format. X-Git-Tag: v0.0.5~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52d2066995447322bf6da8ec1fade271b87c7a87;p=icinga2 Avoid temporary String objects in PerfdataValue::Format. Fixes #5248 --- diff --git a/lib/icinga/perfdatavalue.cpp b/lib/icinga/perfdatavalue.cpp index 549a7cdcb..d9a7a6a67 100644 --- a/lib/icinga/perfdatavalue.cpp +++ b/lib/icinga/perfdatavalue.cpp @@ -112,8 +112,9 @@ String PerfdataValue::Format(const Value& perfdata) { if (perfdata.IsObjectType()) { PerfdataValue::Ptr pdv = perfdata; + std::ostringstream result; - String output = Convert::ToString(pdv->GetValue()); + result << pdv->GetValue(); String unit; @@ -126,25 +127,25 @@ String PerfdataValue::Format(const Value& perfdata) else if (pdv->GetUnit() == "bytes") unit = "B"; - output += unit; + result << unit; if (!pdv->GetWarn().IsEmpty()) { - output += ";" + pdv->GetWarn(); + result << ";" << pdv->GetWarn(); if (!pdv->GetCrit().IsEmpty()) { - output += ";" + pdv->GetCrit(); + result << ";" << pdv->GetCrit(); if (!pdv->GetMin().IsEmpty()) { - output += ";" + pdv->GetMin(); + result << ";" << pdv->GetMin(); if (!pdv->GetMax().IsEmpty()) { - output += ";" + pdv->GetMax(); + result << ";" << pdv->GetMax(); } } } } - return output; + return result.str(); } else { return perfdata; }