QtCore: eradicate all Q_FOREACH loops [io]
Saves more than 1KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I1a974e903bc8352af800fa26edae0194c1e51705 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
5170c0416b
commit
194e158beb
@ -261,7 +261,7 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
|
||||
*/
|
||||
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
|
||||
|
||||
foreach (const QString &s, selectors) {
|
||||
for (const QString &s : selectors) {
|
||||
QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');
|
||||
QStringList remainingSelectors = selectors;
|
||||
remainingSelectors.removeAll(s);
|
||||
|
@ -246,7 +246,7 @@ QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject
|
||||
QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine()
|
||||
{
|
||||
notifier.setEnabled(false);
|
||||
foreach (int id, pathToID)
|
||||
for (int id : qAsConst(pathToID))
|
||||
inotify_rm_watch(inotifyFd, id < 0 ? -id : id);
|
||||
|
||||
::close(inotifyFd);
|
||||
|
@ -82,7 +82,7 @@ QKqueueFileSystemWatcherEngine::~QKqueueFileSystemWatcherEngine()
|
||||
notifier.setEnabled(false);
|
||||
close(kqfd);
|
||||
|
||||
foreach (int id, pathToID)
|
||||
for (int id : qAsConst(pathToID))
|
||||
::close(id < 0 ? -id : id);
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
||||
|
||||
// now look for a thread to insert
|
||||
bool found = false;
|
||||
foreach(QWindowsFileSystemWatcherEngineThread *thread, threads) {
|
||||
for (QWindowsFileSystemWatcherEngineThread *thread : qAsConst(threads)) {
|
||||
QMutexLocker(&(thread->mutex));
|
||||
if (thread->handles.count() < MAXIMUM_WAIT_OBJECTS) {
|
||||
DEBUG() << "Added handle" << handle.handle << "for" << absolutePath << "to watch" << fileInfo.absoluteFilePath()
|
||||
@ -311,7 +311,7 @@ QWindowsFileSystemWatcherEngineThread::~QWindowsFileSystemWatcherEngineThread()
|
||||
CloseHandle(handles.at(0));
|
||||
handles[0] = INVALID_HANDLE_VALUE;
|
||||
|
||||
foreach (HANDLE h, handles) {
|
||||
for (HANDLE h : qAsConst(handles)) {
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
continue;
|
||||
FindCloseChangeNotification(h);
|
||||
@ -323,7 +323,7 @@ static inline QString msgFindNextFailed(const QWindowsFileSystemWatcherEngineThr
|
||||
QString result;
|
||||
QTextStream str(&result);
|
||||
str << "QFileSystemWatcher: FindNextChangeNotification failed for";
|
||||
foreach (const QWindowsFileSystemWatcherEngine::PathInfo &pathInfo, pathInfos)
|
||||
for (const QWindowsFileSystemWatcherEngine::PathInfo &pathInfo : pathInfos)
|
||||
str << " \"" << QDir::toNativeSeparators(pathInfo.absolutePath) << '"';
|
||||
str << ' ';
|
||||
return result;
|
||||
|
@ -400,7 +400,7 @@ QLoggingRegistry *QLoggingRegistry::instance()
|
||||
*/
|
||||
void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
|
||||
{
|
||||
QLoggingRegistry *reg = QLoggingRegistry::instance();
|
||||
const QLoggingRegistry *reg = QLoggingRegistry::instance();
|
||||
Q_ASSERT(reg->categories.contains(cat));
|
||||
QtMsgType enableForLevel = reg->categories.value(cat);
|
||||
|
||||
@ -421,7 +421,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
|
||||
}
|
||||
|
||||
QString categoryName = QLatin1String(cat->categoryName());
|
||||
foreach (const QLoggingRule &item, reg->rules) {
|
||||
for (const QLoggingRule &item : reg->rules) {
|
||||
int filterpass = item.pass(categoryName, QtDebugMsg);
|
||||
if (filterpass != 0)
|
||||
debug = (filterpass > 0);
|
||||
|
@ -533,10 +533,10 @@ QStringList QWinRTSettingsPrivate::children(const QString &uKey, ChildSpec spec)
|
||||
const QStringList subContainerList = subContainerNames(container.Get(), spec == AllKeys);
|
||||
|
||||
if (spec == AllKeys) {
|
||||
foreach (const QString &item, subContainerList) {
|
||||
for (const QString &item : subContainerList) {
|
||||
const QString subChildren = uKey.isEmpty() ? item : (uKey + QLatin1Char('/') + item);
|
||||
const QStringList subResult = children(subChildren, ChildKeys);
|
||||
foreach (const QString &subItem, subResult)
|
||||
for (const QString &subItem : subResult)
|
||||
result += item + QLatin1Char('/') + subItem;
|
||||
}
|
||||
}
|
||||
@ -644,7 +644,7 @@ IApplicationDataContainer *QWinRTSettingsPrivate::getContainer(IApplicationDataC
|
||||
return current;
|
||||
const QStringList groupPath = group.split(QLatin1Char('/'), QString::SkipEmptyParts);
|
||||
|
||||
foreach (const QString &subGroup, groupPath) {
|
||||
for (const QString &subGroup : groupPath) {
|
||||
ComPtr<IApplicationDataContainer> sub = subContainer(current, subGroup);
|
||||
if (!sub && create)
|
||||
sub = createSubContainer(current, subGroup);
|
||||
|
@ -443,7 +443,7 @@ static inline QString searchExecutable(const QStringList &searchPaths,
|
||||
const QString &executableName)
|
||||
{
|
||||
const QDir currentDir = QDir::current();
|
||||
foreach (const QString &searchPath, searchPaths) {
|
||||
for (const QString &searchPath : searchPaths) {
|
||||
const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);
|
||||
const QString absPath = checkExecutable(candidate);
|
||||
if (!absPath.isEmpty())
|
||||
@ -462,9 +462,9 @@ static inline QString
|
||||
const QStringList &suffixes)
|
||||
{
|
||||
const QDir currentDir = QDir::current();
|
||||
foreach (const QString &searchPath, searchPaths) {
|
||||
for (const QString &searchPath : searchPaths) {
|
||||
const QString candidateRoot = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);
|
||||
foreach (const QString &suffix, suffixes) {
|
||||
for (const QString &suffix : suffixes) {
|
||||
const QString absPath = checkExecutable(candidateRoot + suffix);
|
||||
if (!absPath.isEmpty())
|
||||
return absPath;
|
||||
@ -505,7 +505,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
|
||||
// Remove trailing slashes, which occur on Windows.
|
||||
const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts);
|
||||
searchPaths.reserve(rawPaths.size());
|
||||
foreach (const QString &rawPath, rawPaths) {
|
||||
for (const QString &rawPath : rawPaths) {
|
||||
QString cleanPath = QDir::cleanPath(rawPath);
|
||||
if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/')))
|
||||
cleanPath.truncate(cleanPath.size() - 1);
|
||||
|
@ -4062,7 +4062,7 @@ QStringList QUrl::toStringList(const QList<QUrl> &urls, FormattingOptions option
|
||||
{
|
||||
QStringList lst;
|
||||
lst.reserve(urls.size());
|
||||
foreach (const QUrl &url, urls)
|
||||
for (const QUrl &url : urls)
|
||||
lst.append(url.toString(options));
|
||||
return lst;
|
||||
|
||||
@ -4078,9 +4078,8 @@ QList<QUrl> QUrl::fromStringList(const QStringList &urls, ParsingMode mode)
|
||||
{
|
||||
QList<QUrl> lst;
|
||||
lst.reserve(urls.size());
|
||||
foreach (const QString &str, urls) {
|
||||
for (const QString &str : urls)
|
||||
lst.append(QUrl(str, mode));
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
@ -154,10 +154,10 @@ inline QList<QPair<QByteArray, QByteArray> > QUrl::encodedQueryItems() const
|
||||
}
|
||||
inline QList<QByteArray> QUrl::allEncodedQueryItemValues(const QByteArray &key) const
|
||||
{
|
||||
QStringList items = QUrlQuery(*this).allQueryItemValues(fromEncodedComponent_helper(key), QUrl::FullyEncoded);
|
||||
const QStringList items = QUrlQuery(*this).allQueryItemValues(fromEncodedComponent_helper(key), QUrl::FullyEncoded);
|
||||
QList<QByteArray> result;
|
||||
result.reserve(items.size());
|
||||
Q_FOREACH (const QString &item, items)
|
||||
for (const QString &item : items)
|
||||
result << item.toLatin1();
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user