Optimization for case when expression has only function. Example fmod(5;2).

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-14 19:20:34 +03:00
parent a869874429
commit cd19fe14cb

View File

@ -123,6 +123,15 @@ qreal Calculator::EvalFormula(const QString &formula)
// Remove "-" from tokens list if exist. If don't do that unary minus operation will broken.
RemoveAll(tokens, QStringLiteral("-"));
for (int i = 0; i < builInFunctions.size(); ++i)
{
if (tokens.isEmpty())
{
break;
}
RemoveAll(tokens, builInFunctions.at(i));
}
if (tokens.isEmpty())
{
return result; // We have found only numbers in expression.
@ -187,11 +196,6 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
}
}
if (builInFunctions.contains(i.value()))
{// We have found built-in function
found = true;
}
if (found == false)
{
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN, i.value(), formula, i.key());