Optimization. Avoid expensive exception calls.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-01-20 12:31:12 +02:00
parent 64e2341f10
commit 7f84a09342
4 changed files with 9 additions and 47 deletions

View File

@ -3679,17 +3679,7 @@ void VPattern::ParseIncrementsElement(const QDomNode &node)
if (domElement.tagName() == TagIncrement)
{
const QString name = GetParametrString(domElement, AttrName, "");
QString desc;
try
{
desc = GetParametrString(domElement, AttrDescription);
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
const QString desc = GetParametrEmptyString(domElement, AttrDescription);
const QString formula = GetParametrString(domElement, AttrFormula, "0");
bool ok = false;
const qreal value = EvalFormula(data, formula, &ok);

View File

@ -207,13 +207,10 @@ namespace
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
{
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;
}

View File

@ -456,16 +456,9 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt
//---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::GetParametrEmptyString(const QDomElement &domElement, const QString &name)
{
QString result;
try
{
result = GetParametrString(domElement, name, "");
}
catch(const VExceptionEmptyParameter &)
{
// do nothing
}
return result;
Q_ASSERT_X(not name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty");
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
return domElement.attribute(name);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -269,26 +269,8 @@ void VMeasurements::ReadMeasurements() const
const QDomElement dom = list.at(i).toElement();
const QString name = GetParametrString(dom, AttrName);
QString description;
try
{
description = GetParametrString(dom, AttrDescription);
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
QString fullName;
try
{
fullName = GetParametrString(dom, AttrFullName);
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
const QString description = GetParametrEmptyString(dom, AttrDescription);
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
QSharedPointer<VMeasurement> meash;
QSharedPointer<VMeasurement> tempMeash;