forked from qt-creator/qt-creator
Don't mix iterator and const_iterator
This avoids unnecessary detaches of the Qt container data.
The mismatches where detected by defining QT_STRICT_ITERATORS;
however, this define violates the ODR (causing linker errors),
and therefore is not added permanently.
Change-Id: Idd336a9c8b394214a820437ef1b92d2101f6101c
GPush-Base: 62b0848b9c
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -705,8 +705,8 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
|
||||
foreach (ClassOrNamespace *u, binding->usings())
|
||||
lookup_helper(name, u, result, processed, binding->_templateId);
|
||||
|
||||
Anonymouses::const_iterator cit = binding->_anonymouses.begin();
|
||||
Anonymouses::const_iterator citEnd = binding->_anonymouses.end();
|
||||
Anonymouses::const_iterator cit = binding->_anonymouses.constBegin();
|
||||
Anonymouses::const_iterator citEnd = binding->_anonymouses.constEnd();
|
||||
for (; cit != citEnd; ++cit) {
|
||||
const AnonymousNameId *anonymousNameId = cit.key();
|
||||
ClassOrNamespace *a = cit.value();
|
||||
@@ -802,8 +802,8 @@ ClassOrNamespace *ClassOrNamespace::lookupType(const Name *name, Block *block)
|
||||
{
|
||||
flush();
|
||||
|
||||
QHash<Block *, ClassOrNamespace *>::const_iterator citBlock = _blocks.find(block);
|
||||
if (citBlock != _blocks.end()) {
|
||||
QHash<Block *, ClassOrNamespace *>::const_iterator citBlock = _blocks.constFind(block);
|
||||
if (citBlock != _blocks.constEnd()) {
|
||||
ClassOrNamespace *nestedBlock = citBlock.value();
|
||||
QSet<ClassOrNamespace *> processed;
|
||||
if (ClassOrNamespace *foundInNestedBlock
|
||||
@@ -815,7 +815,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType(const Name *name, Block *block)
|
||||
}
|
||||
}
|
||||
|
||||
for (citBlock = _blocks.begin(); citBlock != _blocks.end(); ++citBlock) {
|
||||
for (citBlock = _blocks.constBegin(); citBlock != _blocks.constEnd(); ++citBlock) {
|
||||
if (ClassOrNamespace *foundNestedBlock = citBlock.value()->lookupType(name, block))
|
||||
return foundNestedBlock;
|
||||
}
|
||||
@@ -1027,8 +1027,8 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateNestedAnonymousType(
|
||||
const AnonymousNameId *anonymousNameId)
|
||||
{
|
||||
QHash<const AnonymousNameId *, ClassOrNamespace *>::const_iterator cit
|
||||
= _anonymouses.find(anonymousNameId);
|
||||
if (cit != _anonymouses.end()) {
|
||||
= _anonymouses.constFind(anonymousNameId);
|
||||
if (cit != _anonymouses.constEnd()) {
|
||||
return cit.value();
|
||||
} else {
|
||||
ClassOrNamespace *newAnonymous = _factory->allocClassOrNamespace(this);
|
||||
@@ -1083,8 +1083,8 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac
|
||||
}
|
||||
} else {
|
||||
QMap<const TemplateNameId *, ClassOrNamespace *>::const_iterator citInstantiation
|
||||
= reference->_instantiations.find(templId);
|
||||
if (citInstantiation != reference->_instantiations.end())
|
||||
= reference->_instantiations.constFind(templId);
|
||||
if (citInstantiation != reference->_instantiations.constEnd())
|
||||
return citInstantiation.value();
|
||||
TemplateNameId *nonConstTemplId = const_cast<TemplateNameId *>(templId);
|
||||
// make this instantiation looks like specialization which help to find
|
||||
|
@@ -1527,8 +1527,8 @@ void PluginManagerPrivate::profilingSummary() const
|
||||
total += it1.value();
|
||||
}
|
||||
|
||||
Sorter::ConstIterator it2 = sorter.begin();
|
||||
Sorter::ConstIterator et2 = sorter.end();
|
||||
Sorter::ConstIterator it2 = sorter.constBegin();
|
||||
Sorter::ConstIterator et2 = sorter.constEnd();
|
||||
for (; it2 != et2; ++it2)
|
||||
qDebug("%-22s %8dms ( %5.2f%% )", qPrintable(it2.value()->name()),
|
||||
it2.key(), 100.0 * it2.key() / total);
|
||||
|
@@ -438,7 +438,7 @@ void SshConnectionPrivate::handleCurrentPacket()
|
||||
}
|
||||
|
||||
QHash<SshPacketType, HandlerInStates>::ConstIterator it
|
||||
= m_packetHandlers.find(m_incomingPacket.type());
|
||||
= m_packetHandlers.constFind(m_incomingPacket.type());
|
||||
if (it == m_packetHandlers.constEnd()) {
|
||||
m_sendFacility.sendMsgUnimplementedPacket(m_incomingPacket.serverSeqNr());
|
||||
return;
|
||||
|
@@ -104,7 +104,7 @@ bool SshHostKeyDatabase::store(const QString &filePath, QString *error) const
|
||||
SshHostKeyDatabase::KeyLookupResult SshHostKeyDatabase::matchHostKey(const QString &hostName,
|
||||
const QByteArray &key) const
|
||||
{
|
||||
auto it = d->hostKeys.find(hostName);
|
||||
auto it = d->hostKeys.constFind(hostName);
|
||||
if (it == d->hostKeys.constEnd())
|
||||
return KeyLookupNoMatch;
|
||||
if (it.value() == key)
|
||||
|
@@ -681,7 +681,8 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti
|
||||
|
||||
}
|
||||
|
||||
for (GradleProperties::const_iterator it = properties.begin(); it != properties.end(); ++it)
|
||||
for (GradleProperties::const_iterator it = properties.constBegin(); it != properties.constEnd();
|
||||
++it)
|
||||
file.write(it.key() + '=' + it.value() + '\n');
|
||||
|
||||
file.close();
|
||||
|
@@ -521,9 +521,9 @@ ParserTreeItem::ConstPtr Parser::getCachedOrParseDocumentTree(const CPlusPlus::D
|
||||
const QString &fileName = doc->fileName();
|
||||
d->docLocker.lockForRead();
|
||||
ParserTreeItem::ConstPtr item = d->cachedDocTrees.value(fileName);
|
||||
CitCachedDocTreeRevision citCachedDocTreeRevision = d->cachedDocTreesRevision.find(fileName);
|
||||
CitCachedDocTreeRevision citCachedDocTreeRevision = d->cachedDocTreesRevision.constFind(fileName);
|
||||
if (!item.isNull()
|
||||
&& citCachedDocTreeRevision != d->cachedDocTreesRevision.end()
|
||||
&& citCachedDocTreeRevision != d->cachedDocTreesRevision.constEnd()
|
||||
&& citCachedDocTreeRevision.value() == doc->revision()) {
|
||||
d->docLocker.unlock();
|
||||
return item;
|
||||
@@ -759,9 +759,9 @@ QStringList Parser::addProjectNode(const ParserTreeItem::Ptr &item, const Projec
|
||||
// our own files
|
||||
QStringList fileList;
|
||||
|
||||
CitCachedPrjFileLists cit = d->cachedPrjFileLists.find(nodePath);
|
||||
CitCachedPrjFileLists cit = d->cachedPrjFileLists.constFind(nodePath);
|
||||
// try to improve parsing speed by internal cache
|
||||
if (cit != d->cachedPrjFileLists.end()) {
|
||||
if (cit != d->cachedPrjFileLists.constEnd()) {
|
||||
fileList = cit.value();
|
||||
} else {
|
||||
fileList = projectNodeFileList(node);
|
||||
@@ -800,9 +800,9 @@ QStringList Parser::getAllFiles(const ProjectNode *node)
|
||||
|
||||
const QString nodePath = node->path().toString();
|
||||
|
||||
CitCachedPrjFileLists cit = d->cachedPrjFileLists.find(nodePath);
|
||||
CitCachedPrjFileLists cit = d->cachedPrjFileLists.constFind(nodePath);
|
||||
// try to improve parsing speed by internal cache
|
||||
if (cit != d->cachedPrjFileLists.end()) {
|
||||
if (cit != d->cachedPrjFileLists.constEnd()) {
|
||||
fileList = cit.value();
|
||||
} else {
|
||||
fileList = projectNodeFileList(node);
|
||||
|
@@ -80,8 +80,8 @@ void ClearCaseSync::invalidateStatus(const QDir &viewRootDir,
|
||||
|
||||
void ClearCaseSync::invalidateStatusAllFiles()
|
||||
{
|
||||
const StatusMap::ConstIterator send = m_statusMap->end();
|
||||
for (StatusMap::ConstIterator it = m_statusMap->begin(); it != send; ++it)
|
||||
const StatusMap::ConstIterator send = m_statusMap->constEnd();
|
||||
for (StatusMap::ConstIterator it = m_statusMap->constBegin(); it != send; ++it)
|
||||
m_plugin->setStatus(it.key(), FileStatus::Unknown, false);
|
||||
}
|
||||
|
||||
|
@@ -249,8 +249,8 @@ bool CppSourceProcessor::checkFile(const QString &absoluteFilePath) const
|
||||
QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType type)
|
||||
{
|
||||
if (type == IncludeGlobal) {
|
||||
QHash<QString, QString>::ConstIterator it = m_fileNameCache.find(fileName);
|
||||
if (it != m_fileNameCache.end())
|
||||
QHash<QString, QString>::ConstIterator it = m_fileNameCache.constFind(fileName);
|
||||
if (it != m_fileNameCache.constEnd())
|
||||
return it.value();
|
||||
const QString fn = resolveFile_helper(fileName, type);
|
||||
m_fileNameCache.insert(fileName, fn);
|
||||
|
@@ -1850,8 +1850,8 @@ QString GdbEngine::cleanupFullName(const QString &fileName)
|
||||
cleanFilePath.clear();
|
||||
const QString base = FileName::fromString(fileName).fileName();
|
||||
|
||||
QMap<QString, QString>::const_iterator jt = m_baseNameToFullName.find(base);
|
||||
while (jt != m_baseNameToFullName.end() && jt.key() == base) {
|
||||
QMap<QString, QString>::const_iterator jt = m_baseNameToFullName.constFind(base);
|
||||
while (jt != m_baseNameToFullName.constEnd() && jt.key() == base) {
|
||||
// FIXME: Use some heuristics to find the "best" match.
|
||||
return jt.value();
|
||||
//++jt;
|
||||
@@ -4018,7 +4018,7 @@ bool GdbEngine::handleCliDisassemblerResult(const QByteArray &output, Disassembl
|
||||
currentFunction = -1;
|
||||
DisassemblerLines result;
|
||||
result.setBytesLength(dlines.bytesLength());
|
||||
for (LineMap::const_iterator it = lineMap.begin(), et = lineMap.end(); it != et; ++it) {
|
||||
for (LineMap::const_iterator it = lineMap.constBegin(), et = lineMap.constEnd(); it != et; ++it) {
|
||||
LineData d = *it;
|
||||
if (d.function != currentFunction) {
|
||||
if (d.function != -1) {
|
||||
|
@@ -1510,8 +1510,8 @@ void QmlV8DebuggerClient::setCurrentFrameDetails(const QVariant &bodyVal, const
|
||||
d->engine->gotoLocation(stackHandler->currentFrame());
|
||||
|
||||
// Expand watch data that were previously expanded
|
||||
QHash<quint64, QByteArray>::const_iterator itEnd = handlesToLookup.end();
|
||||
for (QHash<quint64, QByteArray>::const_iterator it = handlesToLookup.begin(); it != itEnd; ++it)
|
||||
QHash<quint64, QByteArray>::const_iterator itEnd = handlesToLookup.constEnd();
|
||||
for (QHash<quint64, QByteArray>::const_iterator it = handlesToLookup.constBegin(); it != itEnd; ++it)
|
||||
expandObject(it.value(), it.key());
|
||||
emit stackFrameCompleted();
|
||||
}
|
||||
|
@@ -317,7 +317,7 @@ Utils::Environment MsvcToolChain::readEnvironmentSetting(Utils::Environment& env
|
||||
|
||||
// Now loop through and process them
|
||||
QMap<QString,QString>::const_iterator envIter;
|
||||
for (envIter = envPairs.begin(); envIter!=envPairs.end(); ++envIter) {
|
||||
for (envIter = envPairs.constBegin(); envIter!=envPairs.constEnd(); ++envIter) {
|
||||
const QString expandedValue = winExpandDelayedEnvReferences(envIter.value(), env);
|
||||
if (!expandedValue.isEmpty())
|
||||
result.set(envIter.key(), expandedValue);
|
||||
|
@@ -692,7 +692,7 @@ void SessionManager::setValue(const QString &name, const QVariant &value)
|
||||
|
||||
QVariant SessionManager::value(const QString &name)
|
||||
{
|
||||
QMap<QString, QVariant>::const_iterator it = d->m_values.find(name);
|
||||
QMap<QString, QVariant>::const_iterator it = d->m_values.constFind(name);
|
||||
return (it == d->m_values.constEnd()) ? QVariant() : *it;
|
||||
}
|
||||
|
||||
|
@@ -127,7 +127,7 @@ Utils::Environment WinCEToolChain::readEnvironmentSetting(Utils::Environment &en
|
||||
return result;
|
||||
|
||||
QMap<QString,QString>::const_iterator envPairIter;
|
||||
for (envPairIter = envPairs.begin(); envPairIter!=envPairs.end(); ++envPairIter) {
|
||||
for (envPairIter = envPairs.constBegin(); envPairIter!=envPairs.constEnd(); ++envPairIter) {
|
||||
// Replace the env values with those from the WinCE SDK
|
||||
QString varValue = envPairIter.value();
|
||||
if (envPairIter.key() == QLatin1String("PATH"))
|
||||
|
@@ -154,7 +154,7 @@ void QmlProfilerEventsModelProxy::notesChanged(int typeIndex)
|
||||
}
|
||||
} else {
|
||||
d->notes.remove(typeIndex);
|
||||
QVariantList changedNotes = notesModel->byTypeId(typeIndex);
|
||||
const QVariantList changedNotes = notesModel->byTypeId(typeIndex);
|
||||
if (!changedNotes.isEmpty()) {
|
||||
QStringList newNotes;
|
||||
for (QVariantList::ConstIterator it = changedNotes.begin(); it != changedNotes.end();
|
||||
|
@@ -495,7 +495,7 @@ bool QtVersionManager::isValidId(int id)
|
||||
BaseQtVersion *QtVersionManager::version(int id)
|
||||
{
|
||||
QTC_ASSERT(isLoaded(), return 0);
|
||||
QMap<int, BaseQtVersion *>::const_iterator it = m_versions.find(id);
|
||||
QMap<int, BaseQtVersion *>::const_iterator it = m_versions.constFind(id);
|
||||
if (it == m_versions.constEnd())
|
||||
return 0;
|
||||
return it.value();
|
||||
|
@@ -230,7 +230,7 @@ QVariantMap AbstractRemoteLinuxDeployService::exportDeployTimes() const
|
||||
QVariantList remotePathList;
|
||||
QVariantList timeList;
|
||||
typedef QHash<DeployParameters, QDateTime>::ConstIterator DepIt;
|
||||
for (DepIt it = d->lastDeployed.begin(); it != d->lastDeployed.end(); ++it) {
|
||||
for (DepIt it = d->lastDeployed.constBegin(); it != d->lastDeployed.constEnd(); ++it) {
|
||||
fileList << it.key().file.localFilePath().toString();
|
||||
remotePathList << it.key().file.remoteDirectory();
|
||||
hostList << it.key().host;
|
||||
|
@@ -207,7 +207,7 @@ int SnippetsCollection::totalActiveSnippets(const QString &groupId) const
|
||||
{
|
||||
const int group = groupIndex(groupId);
|
||||
return std::distance<QList<Snippet>::const_iterator>(m_snippets.at(group).begin(),
|
||||
m_activeSnippetsEnd.at(group));
|
||||
QList<Snippet>::const_iterator(m_activeSnippetsEnd.at(group)));
|
||||
}
|
||||
|
||||
int SnippetsCollection::totalSnippets(const QString &groupId) const
|
||||
|
@@ -3271,7 +3271,7 @@ void TextEditorWidgetPrivate::insertIntoBlockSelection(const QString &text)
|
||||
const QStringList::const_iterator endLine = textLines.constEnd();
|
||||
for (QStringList::const_iterator textLine = textLines.constBegin(); textLine != endLine; ++textLine)
|
||||
textLength += qMax(0, ts.columnCountForText(*textLine, column) - textLength);
|
||||
for (QStringList::iterator textLine = textLines.begin(); textLine != endLine; ++textLine)
|
||||
for (QStringList::iterator textLine = textLines.begin(); textLine != textLines.end(); ++textLine)
|
||||
textLine->append(QString(qMax(0, textLength - ts.columnCountForText(*textLine, column)), QLatin1Char(' ')));
|
||||
|
||||
// insert Text
|
||||
|
@@ -499,8 +499,9 @@ void TextEditorOverlay::mapEquivalentSelections()
|
||||
const QList<QString> &uniqueKeys = all.uniqueKeys();
|
||||
foreach (const QString &key, uniqueKeys) {
|
||||
QList<int> indexes;
|
||||
QMap<QString, int>::const_iterator lbit = all.lowerBound(key);
|
||||
QMap<QString, int>::const_iterator ubit = all.upperBound(key);
|
||||
const auto cAll = all;
|
||||
QMap<QString, int>::const_iterator lbit = cAll.lowerBound(key);
|
||||
QMap<QString, int>::const_iterator ubit = cAll.upperBound(key);
|
||||
while (lbit != ubit) {
|
||||
indexes.append(lbit.value());
|
||||
++lbit;
|
||||
|
@@ -434,7 +434,7 @@ void ValgrindGlobalSettings::writeSettings() const
|
||||
settings->beginGroup(QLatin1String(groupC));
|
||||
QVariantMap map;
|
||||
toMap(map);
|
||||
for (QVariantMap::ConstIterator it = map.begin(); it != map.end(); ++it)
|
||||
for (QVariantMap::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it)
|
||||
settings->setValue(it.key(), it.value());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
@@ -294,7 +294,7 @@ void Parser::Private::checkProtocolVersion(const QString &versionStr)
|
||||
|
||||
void Parser::Private::checkTool(const QString &reportedStr)
|
||||
{
|
||||
const QHash<QString,Parser::Tool>::ConstIterator reported = toolsByName.find(reportedStr);
|
||||
const QHash<QString,Parser::Tool>::ConstIterator reported = toolsByName.constFind(reportedStr);
|
||||
|
||||
if (reported == toolsByName.constEnd())
|
||||
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
|
||||
@@ -353,7 +353,7 @@ XauxWhat Parser::Private::parseXauxWhat()
|
||||
|
||||
MemcheckErrorKind Parser::Private::parseMemcheckErrorKind(const QString &kind)
|
||||
{
|
||||
const QHash<QString,MemcheckErrorKind>::ConstIterator it = errorKindsByName_memcheck.find(kind);
|
||||
const QHash<QString,MemcheckErrorKind>::ConstIterator it = errorKindsByName_memcheck.constFind(kind);
|
||||
if (it != errorKindsByName_memcheck.constEnd())
|
||||
return *it;
|
||||
else
|
||||
@@ -363,7 +363,7 @@ MemcheckErrorKind Parser::Private::parseMemcheckErrorKind(const QString &kind)
|
||||
|
||||
HelgrindErrorKind Parser::Private::parseHelgrindErrorKind(const QString &kind)
|
||||
{
|
||||
const QHash<QString,HelgrindErrorKind>::ConstIterator it = errorKindsByName_helgrind.find(kind);
|
||||
const QHash<QString,HelgrindErrorKind>::ConstIterator it = errorKindsByName_helgrind.constFind(kind);
|
||||
if (it != errorKindsByName_helgrind.constEnd())
|
||||
return *it;
|
||||
else
|
||||
@@ -373,7 +373,7 @@ HelgrindErrorKind Parser::Private::parseHelgrindErrorKind(const QString &kind)
|
||||
|
||||
PtrcheckErrorKind Parser::Private::parsePtrcheckErrorKind(const QString &kind)
|
||||
{
|
||||
const QHash<QString,PtrcheckErrorKind>::ConstIterator it = errorKindsByName_ptrcheck.find(kind);
|
||||
const QHash<QString,PtrcheckErrorKind>::ConstIterator it = errorKindsByName_ptrcheck.constFind(kind);
|
||||
if (it != errorKindsByName_ptrcheck.constEnd())
|
||||
return *it;
|
||||
else
|
||||
|
@@ -139,7 +139,7 @@ QStringList FindKeyOperation::findKey(const QVariant &in, const QString &key, co
|
||||
{
|
||||
QStringList result;
|
||||
if (in.type() == QVariant::Map) {
|
||||
QVariantMap map = in.toMap();
|
||||
const QVariantMap map = in.toMap();
|
||||
for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) {
|
||||
QString pfx = prefix;
|
||||
if (!pfx.isEmpty())
|
||||
|
@@ -152,7 +152,7 @@ QStringList FindValueOperation::findValue(const QVariant &in, const QVariant &va
|
||||
if (in.type() == value.type() && in == value) {
|
||||
result << prefix;
|
||||
} else if (in.type() == QVariant::Map) {
|
||||
QVariantMap map = in.toMap();
|
||||
const QVariantMap map = in.toMap();
|
||||
for (QVariantMap::const_iterator i = map.begin(); i != map.end(); ++i) {
|
||||
QString pfx = prefix;
|
||||
if (!pfx.isEmpty())
|
||||
|
Reference in New Issue
Block a user