Speed optimization for method VCommonSettings::GetCurveApproximationScale().
--HG-- branch : develop
This commit is contained in:
parent
7f84a09342
commit
7dc29c0f00
|
@ -95,6 +95,9 @@ const QString settingLabelUserDateFormats = QStringLiteral("label/userDateFormat
|
||||||
const QString settingLabelTimeFormat = QStringLiteral("label/timeFormat");
|
const QString settingLabelTimeFormat = QStringLiteral("label/timeFormat");
|
||||||
const QString settingLabelUserTimeFormats = QStringLiteral("label/userTimeFormats");
|
const QString settingLabelUserTimeFormats = QStringLiteral("label/userTimeFormats");
|
||||||
|
|
||||||
|
// Reading settings file is very expensive, cache curve approximation to speed up getting value
|
||||||
|
qreal curveApproximationCached = -1;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
|
QStringList ClearFormats(const QStringList &predefinedFormats, QStringList formats)
|
||||||
{
|
{
|
||||||
|
@ -1005,25 +1008,31 @@ void VCommonSettings::SetUserDefinedTimeFormats(const QStringList &formats)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VCommonSettings::GetCurveApproximationScale() const
|
qreal VCommonSettings::GetCurveApproximationScale() const
|
||||||
|
{
|
||||||
|
if (curveApproximationCached < 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const qreal scale = value(settingPatternCurveApproximationScale, defCurveApproximationScale).toDouble(&ok);
|
const qreal scale = value(settingPatternCurveApproximationScale, defCurveApproximationScale).toDouble(&ok);
|
||||||
if (ok && scale >= minCurveApproximationScale && scale <= maxCurveApproximationScale)
|
if (ok && scale >= minCurveApproximationScale && scale <= maxCurveApproximationScale)
|
||||||
{
|
{
|
||||||
return scale;
|
curveApproximationCached = scale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return defCurveApproximationScale;
|
curveApproximationCached = defCurveApproximationScale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return curveApproximationCached;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VCommonSettings::SetCurveApproximationScale(qreal value)
|
void VCommonSettings::SetCurveApproximationScale(qreal value)
|
||||||
{
|
{
|
||||||
if (value >= minCurveApproximationScale && value <= maxCurveApproximationScale)
|
if (value >= minCurveApproximationScale && value <= maxCurveApproximationScale)
|
||||||
{
|
{
|
||||||
setValue(settingPatternCurveApproximationScale, value);
|
setValue(settingPatternCurveApproximationScale, value);
|
||||||
|
curveApproximationCached = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user