Speed optmization for method VContainer::ClearVariables().
--HG-- branch : develop
This commit is contained in:
parent
49c091be38
commit
d03cd7be06
|
@ -4148,13 +4148,13 @@ void VPattern::PrepareForParse(const Document &parse)
|
||||||
{
|
{
|
||||||
VContainer::ClearUniqueNames();
|
VContainer::ClearUniqueNames();
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||||
data->ClearVariables(VarType::Increment);
|
data->ClearVariables(QVector<VarType>({VarType::Increment,
|
||||||
data->ClearVariables(VarType::LineAngle);
|
VarType::LineAngle,
|
||||||
data->ClearVariables(VarType::LineLength);
|
VarType::LineLength,
|
||||||
data->ClearVariables(VarType::CurveLength);
|
VarType::CurveLength,
|
||||||
data->ClearVariables(VarType::CurveCLength);
|
VarType::CurveCLength,
|
||||||
data->ClearVariables(VarType::ArcRadius);
|
VarType::ArcRadius,
|
||||||
data->ClearVariables(VarType::CurveAngle);
|
VarType::CurveAngle}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,12 @@ public:
|
||||||
// When we create an increment in the dialog it will get neccesary data. Such data must be removed because will
|
// When we create an increment in the dialog it will get neccesary data. Such data must be removed because will
|
||||||
// confuse a user. Increment should not know nothing about internal variables.
|
// confuse a user. Increment should not know nothing about internal variables.
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||||
this->data.ClearVariables(VarType::LineAngle);
|
this->data.ClearVariables(QVector<VarType>({VarType::LineAngle,
|
||||||
this->data.ClearVariables(VarType::LineLength);
|
VarType::LineLength,
|
||||||
this->data.ClearVariables(VarType::CurveLength);
|
VarType::CurveLength,
|
||||||
this->data.ClearVariables(VarType::CurveCLength);
|
VarType::CurveCLength,
|
||||||
this->data.ClearVariables(VarType::ArcRadius);
|
VarType::ArcRadius,
|
||||||
this->data.ClearVariables(VarType::CurveAngle);
|
VarType::CurveAngle}));
|
||||||
}
|
}
|
||||||
|
|
||||||
VIncrementData(const VIncrementData &incr)
|
VIncrementData(const VIncrementData &incr)
|
||||||
|
|
|
@ -281,13 +281,13 @@ void VContainer::ClearForFullParse()
|
||||||
d->pieces->clear();
|
d->pieces->clear();
|
||||||
d->piecePaths->clear();
|
d->piecePaths->clear();
|
||||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||||
ClearVariables(VarType::Increment);
|
ClearVariables(QVector<VarType>({VarType::Increment,
|
||||||
ClearVariables(VarType::LineAngle);
|
VarType::LineAngle,
|
||||||
ClearVariables(VarType::LineLength);
|
VarType::LineLength,
|
||||||
ClearVariables(VarType::CurveLength);
|
VarType::CurveLength,
|
||||||
ClearVariables(VarType::CurveCLength);
|
VarType::CurveCLength,
|
||||||
ClearVariables(VarType::ArcRadius);
|
VarType::ArcRadius,
|
||||||
ClearVariables(VarType::CurveAngle);
|
VarType::CurveAngle}));
|
||||||
ClearGObjects();
|
ClearGObjects();
|
||||||
ClearUniqueNames();
|
ClearUniqueNames();
|
||||||
}
|
}
|
||||||
|
@ -311,27 +311,31 @@ void VContainer::ClearCalculationGObjects()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VContainer::ClearVariables(const VarType &type)
|
void VContainer::ClearVariables(const VarType &type)
|
||||||
{
|
{
|
||||||
if (d->variables.size()>0) //-V807
|
ClearVariables(QVector<VarType>({type}));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VContainer::ClearVariables(const QVector<VarType> &types)
|
||||||
|
{
|
||||||
|
if (not d->variables.isEmpty()) //-V807
|
||||||
{
|
{
|
||||||
if (type == VarType::Unknown)
|
if (types.isEmpty() || types.contains(VarType::Unknown))
|
||||||
{
|
{
|
||||||
d->variables.clear();
|
d->variables.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QVector<QString> keys;
|
|
||||||
QHash<QString, QSharedPointer<VInternalVariable> >::iterator i;
|
QHash<QString, QSharedPointer<VInternalVariable> >::iterator i;
|
||||||
for (i = d->variables.begin(); i != d->variables.end(); ++i)
|
for (i = d->variables.begin(); i != d->variables.end();)
|
||||||
{
|
{
|
||||||
if (i.value()->GetType() == type)
|
if (types.contains(i.value()->GetType()))
|
||||||
{
|
{
|
||||||
keys.append(i.key());
|
i = d->variables.erase(i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < keys.size(); ++i)
|
|
||||||
{
|
|
||||||
d->variables.remove(keys.at(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,7 @@ public:
|
||||||
void ClearGObjects();
|
void ClearGObjects();
|
||||||
void ClearCalculationGObjects();
|
void ClearCalculationGObjects();
|
||||||
void ClearVariables(const VarType &type = VarType::Unknown);
|
void ClearVariables(const VarType &type = VarType::Unknown);
|
||||||
|
void ClearVariables(const QVector<VarType> &types);
|
||||||
static void ClearUniqueNames();
|
static void ClearUniqueNames();
|
||||||
static void ClearUniqueIncrementNames();
|
static void ClearUniqueIncrementNames();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user