forked from qt-creator/qt-creator
QmlJs: use initilizer_lists for pairs
Change-Id: I0386d57ad3549814ab197c4e24549705e061c95a Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -1397,11 +1397,11 @@ bool Check::visit(CaseBlock *ast)
|
|||||||
{
|
{
|
||||||
QList< QPair<SourceLocation, StatementList *> > clauses;
|
QList< QPair<SourceLocation, StatementList *> > clauses;
|
||||||
for (CaseClauses *it = ast->clauses; it; it = it->next)
|
for (CaseClauses *it = ast->clauses; it; it = it->next)
|
||||||
clauses += qMakePair(it->clause->caseToken, it->clause->statements);
|
clauses += {it->clause->caseToken, it->clause->statements};
|
||||||
if (ast->defaultClause)
|
if (ast->defaultClause)
|
||||||
clauses += qMakePair(ast->defaultClause->defaultToken, ast->defaultClause->statements);
|
clauses += {ast->defaultClause->defaultToken, ast->defaultClause->statements};
|
||||||
for (CaseClauses *it = ast->moreClauses; it; it = it->next)
|
for (CaseClauses *it = ast->moreClauses; it; it = it->next)
|
||||||
clauses += qMakePair(it->clause->caseToken, it->clause->statements);
|
clauses += {it->clause->caseToken, it->clause->statements};
|
||||||
|
|
||||||
// check all but the last clause for fallthrough
|
// check all but the last clause for fallthrough
|
||||||
for (int i = 0; i < clauses.size() - 1; ++i) {
|
for (int i = 0; i < clauses.size() - 1; ++i) {
|
||||||
|
@@ -1232,7 +1232,7 @@ void ModelManagerInterface::queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr
|
|||||||
QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->fileName());
|
QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->fileName());
|
||||||
if (prev.first && prev.second)
|
if (prev.first && prev.second)
|
||||||
prev.first->releaseSourceAndAST();
|
prev.first->releaseSourceAndAST();
|
||||||
m_queuedCppDocuments.insert(doc->fileName(), qMakePair(doc, scan));
|
m_queuedCppDocuments.insert(doc->fileName(), {doc, scan});
|
||||||
m_updateCppQmlTypesTimer->start();
|
m_updateCppQmlTypesTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ public:
|
|||||||
typedef QHash<QString, QPair<QString, int> > Table;
|
typedef QHash<QString, QPair<QString, int> > Table;
|
||||||
|
|
||||||
void insert(const QString &fileName, const QString &source, int revision = 0)
|
void insert(const QString &fileName, const QString &source, int revision = 0)
|
||||||
{ _elements.insert(fileName, qMakePair(source, revision)); }
|
{ _elements.insert(fileName, {source, revision}); }
|
||||||
|
|
||||||
bool contains(const QString &fileName) const
|
bool contains(const QString &fileName) const
|
||||||
{ return _elements.contains(fileName); }
|
{ return _elements.contains(fileName); }
|
||||||
|
@@ -487,7 +487,7 @@ QrcParser::Ptr QrcCachePrivate::addPath(const QString &path, const QString &cont
|
|||||||
QPair<QrcParser::Ptr,int> currentValue;
|
QPair<QrcParser::Ptr,int> currentValue;
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
currentValue = m_cache.value(path, qMakePair(QrcParser::Ptr(0), 0));
|
currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
||||||
currentValue.second += 1;
|
currentValue.second += 1;
|
||||||
if (currentValue.second > 1) {
|
if (currentValue.second > 1) {
|
||||||
m_cache.insert(path, currentValue);
|
m_cache.insert(path, currentValue);
|
||||||
@@ -499,7 +499,7 @@ QrcParser::Ptr QrcCachePrivate::addPath(const QString &path, const QString &cont
|
|||||||
qCWarning(qmljsLog) << "adding invalid qrc " << path << " to the cache:" << newParser->errorMessages();
|
qCWarning(qmljsLog) << "adding invalid qrc " << path << " to the cache:" << newParser->errorMessages();
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, qMakePair(QrcParser::Ptr(0), 0));
|
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
||||||
if (currentValue.first.isNull())
|
if (currentValue.first.isNull())
|
||||||
currentValue.first = newParser;
|
currentValue.first = newParser;
|
||||||
currentValue.second += 1;
|
currentValue.second += 1;
|
||||||
@@ -513,7 +513,7 @@ void QrcCachePrivate::removePath(const QString &path)
|
|||||||
QPair<QrcParser::Ptr,int> currentValue;
|
QPair<QrcParser::Ptr,int> currentValue;
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
currentValue = m_cache.value(path, qMakePair(QrcParser::Ptr(0), 0));
|
currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
||||||
if (currentValue.second == 1) {
|
if (currentValue.second == 1) {
|
||||||
m_cache.remove(path);
|
m_cache.remove(path);
|
||||||
} else if (currentValue.second > 1) {
|
} else if (currentValue.second > 1) {
|
||||||
@@ -530,7 +530,7 @@ QrcParser::Ptr QrcCachePrivate::updatePath(const QString &path, const QString &c
|
|||||||
QrcParser::Ptr newParser = QrcParser::parseQrcFile(path, contents);
|
QrcParser::Ptr newParser = QrcParser::parseQrcFile(path, contents);
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, qMakePair(QrcParser::Ptr(0), 0));
|
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
||||||
currentValue.first = newParser;
|
currentValue.first = newParser;
|
||||||
if (currentValue.second == 0)
|
if (currentValue.second == 0)
|
||||||
currentValue.second = 1; // add qrc files that are not in the resources of a project
|
currentValue.second = 1; // add qrc files that are not in the resources of a project
|
||||||
@@ -542,7 +542,7 @@ QrcParser::Ptr QrcCachePrivate::updatePath(const QString &path, const QString &c
|
|||||||
QrcParser::Ptr QrcCachePrivate::parsedPath(const QString &path)
|
QrcParser::Ptr QrcCachePrivate::parsedPath(const QString &path)
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, qMakePair(QrcParser::Ptr(0), 0));
|
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
||||||
return currentValue.first;
|
return currentValue.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user