Optimization for case when expression has only function. Example fmod(5;2).
--HG-- branch : develop
This commit is contained in:
parent
a869874429
commit
cd19fe14cb
|
@ -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.
|
// Remove "-" from tokens list if exist. If don't do that unary minus operation will broken.
|
||||||
RemoveAll(tokens, QStringLiteral("-"));
|
RemoveAll(tokens, QStringLiteral("-"));
|
||||||
|
|
||||||
|
for (int i = 0; i < builInFunctions.size(); ++i)
|
||||||
|
{
|
||||||
|
if (tokens.isEmpty())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RemoveAll(tokens, builInFunctions.at(i));
|
||||||
|
}
|
||||||
|
|
||||||
if (tokens.isEmpty())
|
if (tokens.isEmpty())
|
||||||
{
|
{
|
||||||
return result; // We have found only numbers in expression.
|
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)
|
if (found == false)
|
||||||
{
|
{
|
||||||
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN, i.value(), formula, i.key());
|
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN, i.value(), formula, i.key());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user