mirror of
https://gitlab.com/smart-pattern/valentina.git
synced 2024-09-19 23:34:04 +02:00
Declare variables inside the loop.
This commit is contained in:
parent
21f3a5dc78
commit
c696ba0e1a
|
@ -2611,8 +2611,7 @@ void TMainWindow::ExportToIndividual()
|
|||
VMeasurements individualMeasurements(m_mUnit, tmpData.data());
|
||||
|
||||
const QMap<int, QSharedPointer<VMeasurement>> orderedTable = OrderedMeasurements();
|
||||
QMap<int, QSharedPointer<VMeasurement>>::const_iterator iMap;
|
||||
for (iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap)
|
||||
for (auto iMap = orderedTable.constBegin(); iMap != orderedTable.constEnd(); ++iMap)
|
||||
{
|
||||
const QSharedPointer<VMeasurement> &meash = iMap.value();
|
||||
individualMeasurements.AddEmpty(meash->GetName());
|
||||
|
@ -4680,8 +4679,7 @@ auto TMainWindow::OrderedMeasurements() const -> QMap<int, QSharedPointer<VMeasu
|
|||
{
|
||||
const QMap<QString, QSharedPointer<VMeasurement>> table = m_data->DataMeasurementsWithSeparators();
|
||||
QMap<int, QSharedPointer<VMeasurement>> orderedTable;
|
||||
QMap<QString, QSharedPointer<VMeasurement>>::const_iterator iterMap;
|
||||
for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap)
|
||||
for (auto iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap)
|
||||
{
|
||||
const QSharedPointer<VMeasurement> &meash = iterMap.value();
|
||||
orderedTable.insert(meash->Index(), meash);
|
||||
|
|
|
@ -1401,10 +1401,9 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
|
|||
table->blockSignals(true);
|
||||
table->clearContents();
|
||||
|
||||
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i;
|
||||
QMap<quint32, QString> map;
|
||||
// Sorting QHash by id
|
||||
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
for (auto i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
{
|
||||
const QSharedPointer<VIncrement> &incr = i.value();
|
||||
if (takePreviewCalculations == incr->IsPreviewCalculation())
|
||||
|
|
|
@ -1950,10 +1950,9 @@ void MainWindow::ExportToCSVData(const QString &fileName, bool withHeader, int m
|
|||
|
||||
auto SavePreviewCalculation = [¤tRow, &csv, increments](bool save)
|
||||
{
|
||||
QMap<QString, QSharedPointer<VIncrement>>::const_iterator i;
|
||||
QMap<quint32, QString> map;
|
||||
// Sorting QHash by id
|
||||
for (i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
for (auto i = increments.constBegin(); i != increments.constEnd(); ++i)
|
||||
{
|
||||
const QSharedPointer<VIncrement> &incr = i.value();
|
||||
if (incr->IsPreviewCalculation() == save)
|
||||
|
|
|
@ -905,8 +905,7 @@ auto MainWindowsNoGUI::PrepareDetailsForLayout(const QVector<DetailForLayout> &d
|
|||
layoutDetails.reserve(details.size());
|
||||
const QFuture<VLayoutPiece> future = futureWatcher.future();
|
||||
|
||||
QFuture<VLayoutPiece>::const_iterator i;
|
||||
for (i = future.constBegin(); i != future.constEnd(); ++i)
|
||||
for (auto i = future.constBegin(); i != future.constEnd(); ++i)
|
||||
{
|
||||
layoutDetails.append(*i);
|
||||
}
|
||||
|
|
|
@ -1910,8 +1910,6 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
|
|||
{
|
||||
CreateRPN();
|
||||
|
||||
int i = 0;
|
||||
|
||||
#ifdef QMUP_USE_OPENMP
|
||||
// #define DEBUG_OMP_STUFF
|
||||
#ifdef DEBUG_OMP_STUFF
|
||||
|
@ -1924,7 +1922,7 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
|
|||
omp_set_num_threads(nMaxThreads);
|
||||
|
||||
#pragma omp parallel for schedule(static, nBulkSize / nMaxThreads) private(nThreadID)
|
||||
for (i = 0; i < nBulkSize; ++i)
|
||||
for (int i = 0; i < nBulkSize; ++i)
|
||||
{
|
||||
int nThreadID = omp_get_thread_num();
|
||||
results[i] = ParseCmdCodeBulk(i, nThreadID);
|
||||
|
@ -1953,7 +1951,7 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const
|
|||
#endif
|
||||
|
||||
#else
|
||||
for (i = 0; i < nBulkSize; ++i)
|
||||
for (int i = 0; i < nBulkSize; ++i)
|
||||
{
|
||||
results[i] = ParseCmdCodeBulk(i, 0);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
|
||||
#include "qmuparsertokenreader.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <QList>
|
||||
#include <QMessageLogger>
|
||||
#include <QStringList>
|
||||
#include <QtDebug>
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
@ -52,15 +52,26 @@ namespace qmu
|
|||
* @throw nothrow
|
||||
*/
|
||||
QmuParserTokenReader::QmuParserTokenReader(const QmuParserTokenReader &a_Reader)
|
||||
:m_pParser( a_Reader.m_pParser ), m_strFormula( a_Reader.m_strFormula ), m_iPos( a_Reader.m_iPos ),
|
||||
m_iSynFlags( a_Reader.m_iSynFlags ), m_bIgnoreUndefVar( a_Reader.m_bIgnoreUndefVar ),
|
||||
m_pFunDef( a_Reader.m_pFunDef ), m_pPostOprtDef( a_Reader.m_pPostOprtDef ),
|
||||
m_pInfixOprtDef( a_Reader.m_pInfixOprtDef ), m_pOprtDef( a_Reader.m_pOprtDef),
|
||||
m_pConstDef( a_Reader.m_pConstDef ), m_pStrVarDef( a_Reader.m_pStrVarDef ), m_pVarDef( a_Reader.m_pVarDef ),
|
||||
m_pFactory( a_Reader.m_pFactory ), m_pFactoryData( a_Reader.m_pFactoryData ), m_vIdentFun( a_Reader.m_vIdentFun ),
|
||||
m_UsedVar( a_Reader.m_UsedVar ), m_iBrackets( a_Reader.m_iBrackets ),
|
||||
: m_pParser(a_Reader.m_pParser),
|
||||
m_strFormula(a_Reader.m_strFormula),
|
||||
m_iPos(a_Reader.m_iPos),
|
||||
m_iSynFlags(a_Reader.m_iSynFlags),
|
||||
m_bIgnoreUndefVar(a_Reader.m_bIgnoreUndefVar),
|
||||
m_pFunDef(a_Reader.m_pFunDef),
|
||||
m_pPostOprtDef(a_Reader.m_pPostOprtDef),
|
||||
m_pInfixOprtDef(a_Reader.m_pInfixOprtDef),
|
||||
m_pOprtDef(a_Reader.m_pOprtDef),
|
||||
m_pConstDef(a_Reader.m_pConstDef),
|
||||
m_pStrVarDef(a_Reader.m_pStrVarDef),
|
||||
m_pVarDef(a_Reader.m_pVarDef),
|
||||
m_pFactory(a_Reader.m_pFactory),
|
||||
m_pFactoryData(a_Reader.m_pFactoryData),
|
||||
m_vIdentFun(a_Reader.m_vIdentFun),
|
||||
m_UsedVar(a_Reader.m_UsedVar),
|
||||
m_iBrackets(a_Reader.m_iBrackets),
|
||||
m_cArgSep(a_Reader.m_cArgSep)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -318,8 +329,8 @@ void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent )
|
|||
*/
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_MSVC(4309)
|
||||
auto QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok,
|
||||
qmusizetype a_iPos ) const -> qmusizetype
|
||||
auto QmuParserTokenReader::ExtractToken(const QString &a_szCharSet, QString &a_sTok, qmusizetype a_iPos) const
|
||||
-> qmusizetype
|
||||
{
|
||||
qmusizetype iEnd = FindFirstNotOf(m_strFormula, a_szCharSet, a_iPos);
|
||||
|
||||
|
@ -636,8 +647,7 @@ auto QmuParserTokenReader::IsOprt ( token_type &a_Tok ) -> bool
|
|||
// Check if the operator is a built in operator, if so ignore it here
|
||||
const QStringList &pOprtDef = QmuParserBase::GetOprtDef();
|
||||
for (auto constIterator = pOprtDef.constBegin();
|
||||
m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd();
|
||||
++constIterator )
|
||||
m_pParser->HasBuiltInOprt() && constIterator != pOprtDef.constEnd(); ++constIterator)
|
||||
{
|
||||
if ((*constIterator) == strTok)
|
||||
{
|
||||
|
@ -779,8 +789,7 @@ auto QmuParserTokenReader::IsValTok ( token_type &a_Tok, const QLocale &locale,
|
|||
|
||||
// 3.call the value recognition functions provided by the user
|
||||
// Call user defined value recognition functions
|
||||
auto item = m_vIdentFun.begin();
|
||||
for ( item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item )
|
||||
for (auto item = m_vIdentFun.begin(); item != m_vIdentFun.end(); ++item)
|
||||
{
|
||||
qmusizetype const iStart = m_iPos;
|
||||
if ((*item)(m_strFormula.mid(m_iPos), &m_iPos, &fVal, locale, cNumbers, decimal, thousand) == 1)
|
||||
|
@ -883,7 +892,6 @@ auto QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) -> bool
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Check wheter a token at a given position is an undefined variable.
|
||||
|
@ -946,7 +954,6 @@ auto QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) -> bool
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Check wheter a token at a given position is a string.
|
||||
|
|
|
@ -234,8 +234,7 @@ auto DRW_Converter::toUtf8(const std::string &s) -> std::string
|
|||
{
|
||||
std::string result;
|
||||
unsigned int j = 0;
|
||||
unsigned int i = 0;
|
||||
for (i = 0; i < s.length(); i++)
|
||||
for (unsigned int i = 0; i < s.length(); i++)
|
||||
{
|
||||
auto c = static_cast<unsigned char>(s.at(i));
|
||||
if (c < 0x80)
|
||||
|
|
|
@ -620,10 +620,9 @@ template <class T> inline auto VAbstractPiece::CheckLoops(QVector<T> points) ->
|
|||
}
|
||||
|
||||
bool loopFound = false;
|
||||
qint32 i;
|
||||
const int maxLoops = 10000; // limit number of loops to be removed
|
||||
|
||||
for (i = 0; i < maxLoops; ++i)
|
||||
for (qint32 i = 0; i < maxLoops; ++i)
|
||||
{
|
||||
points = CheckLoop(points, loopFound);
|
||||
if (not loopFound)
|
||||
|
@ -646,8 +645,7 @@ template <class T> inline auto VAbstractPiece::CheckLoop(const QVector<T> &point
|
|||
QVector<T> ekvPoints;
|
||||
ekvPoints.reserve(points.size());
|
||||
|
||||
qint32 i;
|
||||
for (i = 0; i < points.size(); ++i)
|
||||
for (qint32 i = 0; i < points.size(); ++i)
|
||||
{
|
||||
/*Last three points no need to check.*/
|
||||
/*Triangle can not contain a loop*/
|
||||
|
|
|
@ -601,9 +601,8 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
|
|||
-> bool
|
||||
{
|
||||
const QxtCsvModelPrivate &d_ptr = qxt_d();
|
||||
int row, col, rows, cols;
|
||||
rows = rowCount();
|
||||
cols = columnCount();
|
||||
int rows = rowCount();
|
||||
int cols = columnCount();
|
||||
QString data;
|
||||
if (not dest->isOpen() && not dest->open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
{
|
||||
|
@ -624,7 +623,7 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
|
|||
if (withHeader)
|
||||
{
|
||||
data = QString();
|
||||
for (col = 0; col < cols; ++col)
|
||||
for (int col = 0; col < cols; ++col)
|
||||
{
|
||||
if (col > 0)
|
||||
{
|
||||
|
@ -634,11 +633,11 @@ auto QxtCsvModel::toCSV(QIODevice *dest, QString &error, bool withHeader, QChar
|
|||
}
|
||||
stream << data << Qt::endl;
|
||||
}
|
||||
for (row = 0; row < rows; ++row)
|
||||
for (int row = 0; row < rows; ++row)
|
||||
{
|
||||
const QStringList &rowData = d_ptr.csvData[row];
|
||||
data = QString();
|
||||
for (col = 0; col < cols; ++col)
|
||||
for (int col = 0; col < cols; ++col)
|
||||
{
|
||||
if (col > 0)
|
||||
{
|
||||
|
|
|
@ -163,7 +163,6 @@ void PathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, int
|
|||
qreal x0, y0, x1, y1, xc, yc;
|
||||
qreal d, sfactor, sfactor_sq;
|
||||
qreal th0, th1, th_arc;
|
||||
int i, n_segs;
|
||||
qreal dx, dy, dx1, dy1, Px, Py, check;
|
||||
rx = qAbs(rx);
|
||||
ry = qAbs(ry);
|
||||
|
@ -223,8 +222,8 @@ void PathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, int
|
|||
{
|
||||
th_arc -= 2 * V_PI;
|
||||
}
|
||||
n_segs = qCeil(qAbs(th_arc / (V_PI * 0.5 + 0.001)));
|
||||
for (i = 0; i < n_segs; i++)
|
||||
int n_segs = qCeil(qAbs(th_arc / (V_PI * 0.5 + 0.001)));
|
||||
for (int i = 0; i < n_segs; i++)
|
||||
{
|
||||
PathArcSegment(path, xc, yc, th0 + i * th_arc / n_segs, th0 + (i + 1) * th_arc / n_segs, rx, ry,
|
||||
x_axis_rotation);
|
||||
|
|
|
@ -178,14 +178,13 @@ static void halfedge_free(halfedge_t *d)
|
|||
void del_free_halfedges(delaunay_t *del);
|
||||
void del_free_halfedges(delaunay_t *del)
|
||||
{
|
||||
quint32 i;
|
||||
halfedge_t *d, *sig;
|
||||
|
||||
/* if there is nothing to do */
|
||||
if (del->points == nullptr)
|
||||
return;
|
||||
|
||||
for (i = 0; i <= (del->end_point - del->start_point); i++)
|
||||
for (quint32 i = 0; i <= (del->end_point - del->start_point); i++)
|
||||
{
|
||||
/* free all the halfedges around the point */
|
||||
d = del->points[i]->he;
|
||||
|
@ -985,7 +984,6 @@ static void build_halfedge_face(delaunay_t *del, halfedge_t *d)
|
|||
void del_build_faces(delaunay_t *del);
|
||||
void del_build_faces(delaunay_t *del)
|
||||
{
|
||||
quint32 i;
|
||||
halfedge_t *curr;
|
||||
|
||||
del->num_faces = 0;
|
||||
|
@ -994,7 +992,7 @@ void del_build_faces(delaunay_t *del)
|
|||
/* build external face first */
|
||||
build_halfedge_face(del, del->rightmost_he->pair);
|
||||
|
||||
for (i = del->start_point; i <= del->end_point; i++)
|
||||
for (quint32 i = del->start_point; i <= del->end_point; i++)
|
||||
{
|
||||
curr = del->points[i]->he;
|
||||
|
||||
|
|
|
@ -446,7 +446,6 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
|||
qreal hh;
|
||||
INEXACT qreal product1;
|
||||
qreal product0;
|
||||
int eindex, hindex;
|
||||
qreal enow;
|
||||
INEXACT qreal bvirt;
|
||||
qreal avirt, bround, around;
|
||||
|
@ -457,12 +456,12 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
|||
|
||||
Split(b, bhi, blo);
|
||||
Two_Product_Presplit(e[0], b, bhi, blo, Q, hh);
|
||||
hindex = 0;
|
||||
int hindex = 0;
|
||||
if (hh != 0)
|
||||
{
|
||||
h[hindex++] = hh;
|
||||
}
|
||||
for (eindex = 1; eindex < elen; eindex++)
|
||||
for (int eindex = 1; eindex < elen; eindex++)
|
||||
{
|
||||
enow = e[eindex];
|
||||
Two_Product_Presplit(enow, b, bhi, blo, product1, product0);
|
||||
|
@ -495,10 +494,9 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
|||
auto estimate(int elen, qreal *e) -> qreal
|
||||
{
|
||||
qreal Q;
|
||||
int eindex;
|
||||
|
||||
Q = e[0];
|
||||
for (eindex = 1; eindex < elen; eindex++)
|
||||
for (int eindex = 1; eindex < elen; eindex++)
|
||||
{
|
||||
Q += e[eindex];
|
||||
}
|
||||
|
|
|
@ -428,8 +428,7 @@ void VContainer::ClearVariables(const QVector<VarType> &types)
|
|||
}
|
||||
else
|
||||
{
|
||||
QHash<QString, QSharedPointer<VInternalVariable>>::iterator i;
|
||||
for (i = d->variables.begin(); i != d->variables.end();)
|
||||
for (auto i = d->variables.begin(); i != d->variables.end();)
|
||||
{
|
||||
if (types.contains(i.value()->GetType()))
|
||||
{
|
||||
|
@ -712,8 +711,7 @@ template <typename T> auto VContainer::DataVar(const VarType &type) const -> QMa
|
|||
{
|
||||
QMap<QString, QSharedPointer<T>> map;
|
||||
// Sorting QHash by id
|
||||
QHash<QString, QSharedPointer<VInternalVariable>>::const_iterator i;
|
||||
for (i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
||||
for (auto i = d->variables.constBegin(); i != d->variables.constEnd(); ++i)
|
||||
{
|
||||
if (i.value()->GetType() == type)
|
||||
{
|
||||
|
|
|
@ -173,8 +173,7 @@ void VPE::VObjectProperty::FillList(QComboBox *box, const QMap<QString, quint32>
|
|||
{
|
||||
box->clear();
|
||||
|
||||
QMap<QString, quint32>::const_iterator i;
|
||||
for (i = list.constBegin(); i != list.constEnd(); ++i)
|
||||
for (auto i = list.constBegin(); i != list.constEnd(); ++i)
|
||||
{
|
||||
box->addItem(i.key(), i.value());
|
||||
}
|
||||
|
|
|
@ -203,9 +203,8 @@ void DialogTool::FillComboBoxSplines(QComboBox *box) const
|
|||
box->blockSignals(true);
|
||||
|
||||
const auto *const objs = data->CalculationGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId && IsSpline(i.value()))
|
||||
{
|
||||
|
@ -224,9 +223,8 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box) const
|
|||
box->blockSignals(true);
|
||||
|
||||
const auto *const objs = data->CalculationGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId && IsSplinePath(i.value()))
|
||||
{
|
||||
|
@ -244,8 +242,7 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const
|
|||
SCASSERT(box != nullptr)
|
||||
const auto *const objs = data->CalculationGObjects();
|
||||
QMap<QString, quint32> list;
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != toolId)
|
||||
{
|
||||
|
@ -780,9 +777,8 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
|
|||
box->blockSignals(true);
|
||||
|
||||
const QHash<quint32, QSharedPointer<VGObject>> *objs = data->CalculationGObjects();
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
QMap<QString, quint32> list;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (rule == FillComboBox::NoChildren)
|
||||
{
|
||||
|
|
|
@ -331,8 +331,7 @@ auto VAbstractTool::PointsList() const -> QMap<QString, quint32>
|
|||
{
|
||||
const QHash<quint32, QSharedPointer<VGObject>> *objs = data.CalculationGObjects();
|
||||
QMap<QString, quint32> list;
|
||||
QHash<quint32, QSharedPointer<VGObject>>::const_iterator i;
|
||||
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
for (auto i = objs->constBegin(); i != objs->constEnd(); ++i)
|
||||
{
|
||||
if (i.key() != m_id)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue