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();
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||
data->ClearVariables(VarType::Increment);
|
||||
data->ClearVariables(VarType::LineAngle);
|
||||
data->ClearVariables(VarType::LineLength);
|
||||
data->ClearVariables(VarType::CurveLength);
|
||||
data->ClearVariables(VarType::CurveCLength);
|
||||
data->ClearVariables(VarType::ArcRadius);
|
||||
data->ClearVariables(VarType::CurveAngle);
|
||||
data->ClearVariables(QVector<VarType>({VarType::Increment,
|
||||
VarType::LineAngle,
|
||||
VarType::LineLength,
|
||||
VarType::CurveLength,
|
||||
VarType::CurveCLength,
|
||||
VarType::ArcRadius,
|
||||
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
|
||||
// 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");
|
||||
this->data.ClearVariables(VarType::LineAngle);
|
||||
this->data.ClearVariables(VarType::LineLength);
|
||||
this->data.ClearVariables(VarType::CurveLength);
|
||||
this->data.ClearVariables(VarType::CurveCLength);
|
||||
this->data.ClearVariables(VarType::ArcRadius);
|
||||
this->data.ClearVariables(VarType::CurveAngle);
|
||||
this->data.ClearVariables(QVector<VarType>({VarType::LineAngle,
|
||||
VarType::LineLength,
|
||||
VarType::CurveLength,
|
||||
VarType::CurveCLength,
|
||||
VarType::ArcRadius,
|
||||
VarType::CurveAngle}));
|
||||
}
|
||||
|
||||
VIncrementData(const VIncrementData &incr)
|
||||
|
|
|
@ -281,13 +281,13 @@ void VContainer::ClearForFullParse()
|
|||
d->pieces->clear();
|
||||
d->piecePaths->clear();
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
||||
ClearVariables(VarType::Increment);
|
||||
ClearVariables(VarType::LineAngle);
|
||||
ClearVariables(VarType::LineLength);
|
||||
ClearVariables(VarType::CurveLength);
|
||||
ClearVariables(VarType::CurveCLength);
|
||||
ClearVariables(VarType::ArcRadius);
|
||||
ClearVariables(VarType::CurveAngle);
|
||||
ClearVariables(QVector<VarType>({VarType::Increment,
|
||||
VarType::LineAngle,
|
||||
VarType::LineLength,
|
||||
VarType::CurveLength,
|
||||
VarType::CurveCLength,
|
||||
VarType::ArcRadius,
|
||||
VarType::CurveAngle}));
|
||||
ClearGObjects();
|
||||
ClearUniqueNames();
|
||||
}
|
||||
|
@ -311,27 +311,31 @@ void VContainer::ClearCalculationGObjects()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::ClearVariables(const VarType &type)
|
||||
{
|
||||
if (d->variables.size()>0) //-V807
|
||||
ClearVariables(QVector<VarType>({type}));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::ClearVariables(const QVector<VarType> &types)
|
||||
{
|
||||
if (type == VarType::Unknown)
|
||||
if (not d->variables.isEmpty()) //-V807
|
||||
{
|
||||
if (types.isEmpty() || types.contains(VarType::Unknown))
|
||||
{
|
||||
d->variables.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
QVector<QString> keys;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < keys.size(); ++i)
|
||||
else
|
||||
{
|
||||
d->variables.remove(keys.at(i));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,6 +172,7 @@ public:
|
|||
void ClearGObjects();
|
||||
void ClearCalculationGObjects();
|
||||
void ClearVariables(const VarType &type = VarType::Unknown);
|
||||
void ClearVariables(const QVector<VarType> &types);
|
||||
static void ClearUniqueNames();
|
||||
static void ClearUniqueIncrementNames();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user