QtCore: eradicate all Q_FOREACH loops [kernel]
Saves just 168b in text size on optimized GCC 4.9 Linux AMD64 builds, but most for loops are in non-Linux code. Change-Id: I4f20a65c2e4953011308ff831c9e8fa37a25274b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
6b9c4480bc
commit
6926e0d484
|
|
@ -235,7 +235,7 @@ void QCFSocketNotifier::unregisterSocketNotifier(QSocketNotifier *notifier)
|
|||
void QCFSocketNotifier::removeSocketNotifiers()
|
||||
{
|
||||
// Remove CFSockets from the runloop.
|
||||
foreach (MacSocketInfo *socketInfo, macSockets) {
|
||||
for (MacSocketInfo *socketInfo : qAsConst(macSockets)) {
|
||||
unregisterSocketInfo(socketInfo);
|
||||
delete socketInfo;
|
||||
}
|
||||
|
|
@ -272,9 +272,9 @@ void QCFSocketNotifier::enableSocketNotifiers(CFRunLoopObserverRef ref, CFRunLoo
|
|||
Q_UNUSED(ref);
|
||||
Q_UNUSED(activity);
|
||||
|
||||
QCFSocketNotifier *that = static_cast<QCFSocketNotifier *>(info);
|
||||
const QCFSocketNotifier *that = static_cast<QCFSocketNotifier *>(info);
|
||||
|
||||
foreach (MacSocketInfo *socketInfo, that->macSockets) {
|
||||
for (MacSocketInfo *socketInfo : that->macSockets) {
|
||||
if (!CFSocketIsValid(socketInfo->socket))
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
|
|||
const QStringList wArgv = qWinCmdArgs(QString::fromLocal8Bit(cmdParam));
|
||||
argv.clear();
|
||||
argc = wArgv.size();
|
||||
foreach (const QString &wArg, wArgv)
|
||||
for (const QString &wArg : wArgv)
|
||||
argv.append(_strdup(wArg.toLocal8Bit().constData()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,8 @@ bool QEventDispatcherWinRT::unregisterTimers(QObject *object)
|
|||
}
|
||||
|
||||
Q_D(QEventDispatcherWinRT);
|
||||
foreach (int id, d->timerIdToObject.keys()) {
|
||||
const auto timerIds = d->timerIdToObject.keys(); // ### FIXME: iterate over hash directly? But unregisterTimer() modifies the hash!
|
||||
for (int id : timerIds) {
|
||||
if (d->timerIdToObject.value(id) == object)
|
||||
unregisterTimer(id);
|
||||
}
|
||||
|
|
@ -395,7 +396,7 @@ QList<QAbstractEventDispatcher::TimerInfo> QEventDispatcherWinRT::registeredTime
|
|||
|
||||
Q_D(const QEventDispatcherWinRT);
|
||||
QList<TimerInfo> timerInfos;
|
||||
foreach (const WinRTTimerInfo &info, d->timerInfos) {
|
||||
for (const WinRTTimerInfo &info : d->timerInfos) {
|
||||
if (info.object == object && info.timerId != INVALID_TIMER_ID)
|
||||
timerInfos.append(info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ static jboolean dispatchGenericMotionEvent(JNIEnv *, jclass, jobject event)
|
|||
{
|
||||
jboolean ret = JNI_FALSE;
|
||||
QMutexLocker locker(&g_genericMotionEventListeners()->mutex);
|
||||
foreach (auto listener, g_genericMotionEventListeners()->listeners)
|
||||
for (auto *listener : qAsConst(g_genericMotionEventListeners()->listeners))
|
||||
ret |= listener->handleGenericMotionEvent(event);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ static jboolean dispatchKeyEvent(JNIEnv *, jclass, jobject event)
|
|||
{
|
||||
jboolean ret = JNI_FALSE;
|
||||
QMutexLocker locker(&g_keyEventListeners()->mutex);
|
||||
foreach (auto listener, g_keyEventListeners()->listeners)
|
||||
for (auto *listener : qAsConst(g_keyEventListeners()->listeners))
|
||||
ret |= listener->handleKeyEvent(event);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -349,7 +349,8 @@ QVariant QPpsObjectPrivate::variantFromPpsAttribute(const QPpsAttribute &attribu
|
|||
return attribute.toString();
|
||||
case QPpsAttribute::Array: {
|
||||
QVariantList variantList;
|
||||
Q_FOREACH (const QPpsAttribute &attr, attribute.toList()) {
|
||||
const auto attrs = attribute.toList();
|
||||
for (const QPpsAttribute &attr : attrs) {
|
||||
QVariant variant = variantFromPpsAttribute(attr);
|
||||
if (!variant.isValid())
|
||||
return QVariantList();
|
||||
|
|
|
|||
|
|
@ -652,7 +652,7 @@ static QString find_translation(const QLocale & locale,
|
|||
#endif
|
||||
|
||||
// try explicit locales names first
|
||||
foreach (QString localeName, languages) {
|
||||
for (QString localeName : qAsConst(languages)) {
|
||||
localeName.replace(QLatin1Char('-'), QLatin1Char('_'));
|
||||
|
||||
realname += localeName + suffixOrDotQM;
|
||||
|
|
@ -668,7 +668,7 @@ static QString find_translation(const QLocale & locale,
|
|||
}
|
||||
|
||||
// start guessing
|
||||
foreach (QString localeName, fuzzyLocales) {
|
||||
for (QString localeName : qAsConst(fuzzyLocales)) {
|
||||
for (;;) {
|
||||
int rightmost = localeName.lastIndexOf(QLatin1Char('_'));
|
||||
// no truncations? fail
|
||||
|
|
@ -1046,7 +1046,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
|
|||
}
|
||||
|
||||
searchDependencies:
|
||||
foreach (QTranslator *translator, subTranslators) {
|
||||
for (QTranslator *translator : subTranslators) {
|
||||
QString tn = translator->translate(context, sourceText, comment, n);
|
||||
if (!tn.isNull())
|
||||
return tn;
|
||||
|
|
|
|||
Loading…
Reference in New Issue