mirror of https://github.com/Icinga/icinga2.git
Performance improvements for Value -> double conversions.
This commit is contained in:
parent
604b57da43
commit
babc948cd0
|
@ -59,7 +59,7 @@ Value::Value(const char *value)
|
||||||
*/
|
*/
|
||||||
bool Value::IsEmpty(void) const
|
bool Value::IsEmpty(void) const
|
||||||
{
|
{
|
||||||
return (m_Value.type() == typeid(boost::blank));
|
return (GetType() == ValueEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,16 +79,17 @@ bool Value::IsScalar(void) const
|
||||||
*/
|
*/
|
||||||
bool Value::IsObject(void) const
|
bool Value::IsObject(void) const
|
||||||
{
|
{
|
||||||
return !IsEmpty() && (m_Value.type() == typeid(Object::Ptr));
|
return !IsEmpty() && (GetType() == ValueObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::operator double(void) const
|
Value::operator double(void) const
|
||||||
{
|
{
|
||||||
if (m_Value.type() != typeid(double)) {
|
const double *value = boost::get<double>(&m_Value);
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
return *value;
|
||||||
|
|
||||||
return boost::lexical_cast<double>(m_Value);
|
return boost::lexical_cast<double>(m_Value);
|
||||||
} else {
|
|
||||||
return boost::get<double>(m_Value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::operator String(void) const
|
Value::operator String(void) const
|
||||||
|
|
|
@ -107,7 +107,7 @@ bool IsEmpty(void) const;
|
||||||
ValueType GetType(void) const;
|
ValueType GetType(void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable boost::variant<boost::blank, double, String, Object::Ptr> m_Value;
|
boost::variant<boost::blank, double, String, Object::Ptr> m_Value;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Value Empty;
|
static Value Empty;
|
||||||
|
|
Loading…
Reference in New Issue