Avoid temporary String objects in PerfdataValue::Format.

Fixes #5248
This commit is contained in:
Gunnar Beutner 2013-12-02 12:55:35 +01:00
parent 2a761fb285
commit 52d2066995
1 changed files with 8 additions and 7 deletions

View File

@ -112,8 +112,9 @@ String PerfdataValue::Format(const Value& perfdata)
{
if (perfdata.IsObjectType<PerfdataValue>()) {
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;
}