QString optimizations.
--HG-- branch : develop
This commit is contained in:
parent
e845453f95
commit
862860f016
|
@ -180,21 +180,23 @@ int ReadVal(const QString &formula, qreal &val, const QLocale &locale, const QCh
|
|||
Q_UNUSED(decimalPoint)
|
||||
Q_UNUSED(groupSeparator)
|
||||
|
||||
QSet<QChar> reserved;
|
||||
reserved << positiveSign
|
||||
<< negativeSign
|
||||
<< sign0
|
||||
<< sign1
|
||||
<< sign2
|
||||
<< sign3
|
||||
<< sign4
|
||||
<< sign5
|
||||
<< sign6
|
||||
<< sign7
|
||||
<< sign8
|
||||
<< sign9
|
||||
<< expUpper
|
||||
<< expLower;
|
||||
QSet<QChar> reserved
|
||||
{
|
||||
positiveSign,
|
||||
negativeSign,
|
||||
sign0,
|
||||
sign1,
|
||||
sign2,
|
||||
sign3,
|
||||
sign4,
|
||||
sign5,
|
||||
sign6,
|
||||
sign7,
|
||||
sign8,
|
||||
sign9,
|
||||
expUpper,
|
||||
expLower
|
||||
};
|
||||
|
||||
if (reserved.contains(decimal) || reserved.contains(thousand))
|
||||
{
|
||||
|
@ -244,7 +246,7 @@ int ReadVal(const QString &formula, qreal &val, const QLocale &locale, const QCh
|
|||
{
|
||||
if (decimal == cThousand)
|
||||
{// Handle reverse to C locale case: thousand '.', decimal ','
|
||||
const QChar tmpThousand = '@';
|
||||
const QChar tmpThousand = QLatin1Char('@');
|
||||
buf.replace(thousand, tmpThousand);
|
||||
buf.replace(decimal, cDecimal);
|
||||
buf.replace(tmpThousand, cThousand);
|
||||
|
|
|
@ -438,52 +438,52 @@ void QmuParser::InitCharSets()
|
|||
void QmuParser::InitFun()
|
||||
{
|
||||
// trigonometric helper functions
|
||||
DefineFun("degTorad", DegreeToRadian);
|
||||
DefineFun("radTodeg", RadianToDegree);
|
||||
DefineFun(QStringLiteral("degTorad"), DegreeToRadian);
|
||||
DefineFun(QStringLiteral("radTodeg"), RadianToDegree);
|
||||
|
||||
// trigonometric functions
|
||||
DefineFun("sin", qSin);
|
||||
DefineFun("cos", qCos);
|
||||
DefineFun("tan", qTan);
|
||||
DefineFun("sinD", SinD);
|
||||
DefineFun("cosD", CosD);
|
||||
DefineFun("tanD", TanD);
|
||||
DefineFun(QStringLiteral("sin"), qSin);
|
||||
DefineFun(QStringLiteral("cos"), qCos);
|
||||
DefineFun(QStringLiteral("tan"), qTan);
|
||||
DefineFun(QStringLiteral("sinD"), SinD);
|
||||
DefineFun(QStringLiteral("cosD"), CosD);
|
||||
DefineFun(QStringLiteral("tanD"), TanD);
|
||||
// arcus functions
|
||||
DefineFun("asin", qAsin);
|
||||
DefineFun("acos", qAcos);
|
||||
DefineFun("atan", qAtan);
|
||||
DefineFun("atan2", qAtan2);
|
||||
DefineFun("asinD", ASinD);
|
||||
DefineFun("acosD", ACosD);
|
||||
DefineFun("atanD", ATanD);
|
||||
DefineFun(QStringLiteral("asin"), qAsin);
|
||||
DefineFun(QStringLiteral("acos"), qAcos);
|
||||
DefineFun(QStringLiteral("atan"), qAtan);
|
||||
DefineFun(QStringLiteral("atan2"), qAtan2);
|
||||
DefineFun(QStringLiteral("asinD"), ASinD);
|
||||
DefineFun(QStringLiteral("acosD"), ACosD);
|
||||
DefineFun(QStringLiteral("atanD"), ATanD);
|
||||
// hyperbolic functions
|
||||
DefineFun("sinh", Sinh);
|
||||
DefineFun("cosh", Cosh);
|
||||
DefineFun("tanh", Tanh);
|
||||
DefineFun(QStringLiteral("sinh"), Sinh);
|
||||
DefineFun(QStringLiteral("cosh"), Cosh);
|
||||
DefineFun(QStringLiteral("tanh"), Tanh);
|
||||
// arcus hyperbolic functions
|
||||
DefineFun("asinh", ASinh);
|
||||
DefineFun("acosh", ACosh);
|
||||
DefineFun("atanh", ATanh);
|
||||
DefineFun(QStringLiteral("asinh"), ASinh);
|
||||
DefineFun(QStringLiteral("acosh"), ACosh);
|
||||
DefineFun(QStringLiteral("atanh"), ATanh);
|
||||
// Logarithm functions
|
||||
DefineFun("log2", Log2);
|
||||
DefineFun("log10", Log10);
|
||||
DefineFun("log", Log10);
|
||||
DefineFun("ln", qLn);
|
||||
DefineFun(QStringLiteral("log2"), Log2);
|
||||
DefineFun(QStringLiteral("log10"), Log10);
|
||||
DefineFun(QStringLiteral("log"), Log10);
|
||||
DefineFun(QStringLiteral("ln"), qLn);
|
||||
// misc
|
||||
DefineFun("exp", qExp);
|
||||
DefineFun("sqrt", qSqrt);
|
||||
DefineFun("sign", Sign);
|
||||
DefineFun("rint", Rint);
|
||||
DefineFun("r2cm", R2CM);
|
||||
DefineFun("csrCm", CSRCm);
|
||||
DefineFun("csrInch", CSRInch);
|
||||
DefineFun("abs", Abs);
|
||||
DefineFun("fmod", FMod);
|
||||
DefineFun(QStringLiteral("exp"), qExp);
|
||||
DefineFun(QStringLiteral("sqrt"), qSqrt);
|
||||
DefineFun(QStringLiteral("sign"), Sign);
|
||||
DefineFun(QStringLiteral("rint"), Rint);
|
||||
DefineFun(QStringLiteral("r2cm"), R2CM);
|
||||
DefineFun(QStringLiteral("csrCm"), CSRCm);
|
||||
DefineFun(QStringLiteral("csrInch"), CSRInch);
|
||||
DefineFun(QStringLiteral("abs"), Abs);
|
||||
DefineFun(QStringLiteral("fmod"), FMod);
|
||||
// Functions with variable number of arguments
|
||||
DefineFun("sum", Sum);
|
||||
DefineFun("avg", Avg);
|
||||
DefineFun("min", Min);
|
||||
DefineFun("max", Max);
|
||||
DefineFun(QStringLiteral("sum"), Sum);
|
||||
DefineFun(QStringLiteral("avg"), Avg);
|
||||
DefineFun(QStringLiteral("min"), Min);
|
||||
DefineFun(QStringLiteral("max"), Max);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -436,7 +436,7 @@ void QmuParserBase::SetExpr(const QString &a_sExpr)
|
|||
// when calling tellg on a stringstream created from the expression after
|
||||
// reading a value at the end of an expression. (qmu::QmuParser::IsVal function)
|
||||
// (tellg returns -1 otherwise causing the parser to ignore the value)
|
||||
QString sBuf(a_sExpr + " " );
|
||||
QString sBuf(a_sExpr + QChar(' ') );
|
||||
m_pTokenReader->SetFormula(sBuf);
|
||||
ReInit();
|
||||
}
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
#define QMUP_VERSION "2.6.0"
|
||||
#define QMUP_VERSION_DATE "20180121; GC"
|
||||
|
||||
#define QMUP_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
// Detect whether the compiler supports C++11 noexcept exception specifications.
|
||||
# if defined(__clang__)
|
||||
# if __has_feature(cxx_noexcept)
|
||||
|
|
|
@ -368,7 +368,7 @@ int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) c
|
|||
{
|
||||
// There is still the chance of having to deal with an operator consisting exclusively
|
||||
// of alphabetic characters.
|
||||
return ExtractToken ( QMUP_CHARS, a_sTok, a_iPos );
|
||||
return ExtractToken (QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), a_sTok, a_iPos );
|
||||
}
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
|
|
@ -235,9 +235,8 @@ void VToolFlippingByAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolFlippingByAxis::MakeToolTip() const
|
||||
{
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2</td> </tr>")
|
||||
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>")
|
||||
.arg(tr("Origin point"), OriginPointName());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -222,10 +222,9 @@ void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolFlippingByLine::MakeToolTip() const
|
||||
{
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4</td> </tr>")
|
||||
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4</td> </tr>")
|
||||
.arg(tr("First line point"), FirstLinePointName(), tr("Second line point"), SecondLinePointName());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -668,14 +668,11 @@ QT_WARNING_POP
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractOperation::ComplexPointToolTip(quint32 itemId) const
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(itemId);
|
||||
|
||||
const QString toolTip = QString("<table>"
|
||||
"<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"%3"
|
||||
"</table>")
|
||||
.arg(tr("Label"), point->name(), MakeToolTip());
|
||||
return toolTip;
|
||||
return QStringLiteral("<table>"
|
||||
"<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"%3"
|
||||
"</table>")
|
||||
.arg(tr("Label"), VAbstractTool::data.GetGObject(itemId)->name(), MakeToolTip());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -413,7 +413,7 @@ QString VToolMove::OriginPointName() const
|
|||
{
|
||||
try
|
||||
{
|
||||
return VAbstractTool::data.GetGObject(origPointId)->name();
|
||||
return VAbstractTool::data.GetGObject(origPointId)->name();
|
||||
}
|
||||
catch (const VExceptionBadId &)
|
||||
{
|
||||
|
@ -504,10 +504,10 @@ void VToolMove::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolMove::MakeToolTip() const
|
||||
{
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2°</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||
"<tr> <td><b>%8:</b> %9</td> </tr>")
|
||||
return QStringLiteral("<tr> <td><b>%1:</b> %2°</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
|
||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||
"<tr> <td><b>%8:</b> %9</td> </tr>")
|
||||
.arg(tr("Angle")) // 1
|
||||
.arg(GetFormulaAngle().getDoubleValue()) // 2
|
||||
.arg(tr("Length")) // 3
|
||||
|
@ -517,7 +517,6 @@ QString VToolMove::MakeToolTip() const
|
|||
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
|
||||
.arg(tr("Rotation origin point"), // 8
|
||||
OriginPointName()); // 9
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -371,11 +371,10 @@ void VToolRotation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolRotation::MakeToolTip() const
|
||||
{
|
||||
const QString toolTip = QString("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4°</td> </tr>")
|
||||
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||
"<tr> <td><b>%3:</b> %4°</td> </tr>")
|
||||
.arg(tr("Origin point"), OriginPointName(), tr("Rotation angle"))
|
||||
.arg(GetFormulaAngle().getDoubleValue());
|
||||
return toolTip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user