Optimization. Avoid expensive exception calls.
--HG-- branch : develop
This commit is contained in:
parent
64e2341f10
commit
7f84a09342
|
@ -3679,17 +3679,7 @@ void VPattern::ParseIncrementsElement(const QDomNode &node)
|
||||||
if (domElement.tagName() == TagIncrement)
|
if (domElement.tagName() == TagIncrement)
|
||||||
{
|
{
|
||||||
const QString name = GetParametrString(domElement, AttrName, "");
|
const QString name = GetParametrString(domElement, AttrName, "");
|
||||||
|
const QString desc = GetParametrEmptyString(domElement, AttrDescription);
|
||||||
QString desc;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
desc = GetParametrString(domElement, AttrDescription);
|
|
||||||
}
|
|
||||||
catch (VExceptionEmptyParameter &e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString formula = GetParametrString(domElement, AttrFormula, "0");
|
const QString formula = GetParametrString(domElement, AttrFormula, "0");
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const qreal value = EvalFormula(data, formula, &ok);
|
const qreal value = EvalFormula(data, formula, &ok);
|
||||||
|
|
|
@ -207,13 +207,10 @@ namespace
|
||||||
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
|
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
|
||||||
{
|
{
|
||||||
VFormulaField formula;
|
VFormulaField formula;
|
||||||
try
|
formula.expression = VDomDocument::GetParametrEmptyString(element, attribute);
|
||||||
|
|
||||||
|
if (formula.expression.isEmpty())
|
||||||
{
|
{
|
||||||
formula.expression = VDomDocument::GetParametrString(element, attribute);
|
|
||||||
}
|
|
||||||
catch (VExceptionEmptyParameter &e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(e)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -456,16 +456,9 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VDomDocument::GetParametrEmptyString(const QDomElement &domElement, const QString &name)
|
QString VDomDocument::GetParametrEmptyString(const QDomElement &domElement, const QString &name)
|
||||||
{
|
{
|
||||||
QString result;
|
Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty");
|
||||||
try
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||||
{
|
return domElement.attribute(name);
|
||||||
result = GetParametrString(domElement, name, "");
|
|
||||||
}
|
|
||||||
catch(const VExceptionEmptyParameter &)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -269,26 +269,8 @@ void VMeasurements::ReadMeasurements() const
|
||||||
const QDomElement dom = list.at(i).toElement();
|
const QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
const QString name = GetParametrString(dom, AttrName);
|
const QString name = GetParametrString(dom, AttrName);
|
||||||
|
const QString description = GetParametrEmptyString(dom, AttrDescription);
|
||||||
QString description;
|
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
|
||||||
try
|
|
||||||
{
|
|
||||||
description = GetParametrString(dom, AttrDescription);
|
|
||||||
}
|
|
||||||
catch (VExceptionEmptyParameter &e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fullName;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fullName = GetParametrString(dom, AttrFullName);
|
|
||||||
}
|
|
||||||
catch (VExceptionEmptyParameter &e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
QSharedPointer<VMeasurement> meash;
|
QSharedPointer<VMeasurement> meash;
|
||||||
QSharedPointer<VMeasurement> tempMeash;
|
QSharedPointer<VMeasurement> tempMeash;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user