platformsupport: eradicate some easy Q_FOREACH loops
All loops trivially not modifying the iterated-over container. Saves ~9.4KiB in text size across all plugins and libs (statically) linking in QtPlatformSupport (optimized GCC 6.1 Linux AMD 64 build). Change-Id: I2d91da1f78d9b33d4c5e4a1627560d8e705a9b9a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
919978afae
commit
c47d1d74a7
@ -101,7 +101,8 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices()
|
||||
// check for input devices
|
||||
if (m_types & Device_InputMask) {
|
||||
dir.setPath(QString::fromLatin1(QT_EVDEV_DEVICE_PATH));
|
||||
foreach (const QString &deviceFile, dir.entryList()) {
|
||||
const auto deviceFiles = dir.entryList();
|
||||
for (const QString &deviceFile : deviceFiles) {
|
||||
QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile;
|
||||
if (checkDeviceType(absoluteFilePath))
|
||||
devices << absoluteFilePath;
|
||||
@ -111,7 +112,8 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices()
|
||||
// check for drm devices
|
||||
if (m_types & Device_VideoMask) {
|
||||
dir.setPath(QString::fromLatin1(QT_DRM_DEVICE_PATH));
|
||||
foreach (const QString &deviceFile, dir.entryList()) {
|
||||
const auto deviceFiles = dir.entryList();
|
||||
for (const QString &deviceFile : deviceFiles) {
|
||||
QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile;
|
||||
if (checkDeviceType(absoluteFilePath))
|
||||
devices << absoluteFilePath;
|
||||
|
@ -138,15 +138,16 @@ void QFbScreen::lower(QFbWindow *window)
|
||||
|
||||
QWindow *QFbScreen::topWindow() const
|
||||
{
|
||||
foreach (QFbWindow *fbw, mWindowStack)
|
||||
for (QFbWindow *fbw : mWindowStack) {
|
||||
if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog)
|
||||
return fbw->window();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QWindow *QFbScreen::topLevelAt(const QPoint & p) const
|
||||
{
|
||||
foreach (QFbWindow *fbw, mWindowStack) {
|
||||
for (QFbWindow *fbw : mWindowStack) {
|
||||
if (fbw->geometry().contains(p, false) && fbw->window()->isVisible())
|
||||
return fbw->window();
|
||||
}
|
||||
|
@ -77,7 +77,8 @@ void QBasicFontDatabase::populateFontDatabase()
|
||||
<< QLatin1String("*.pfb")
|
||||
<< QLatin1String("*.otf");
|
||||
|
||||
foreach (const QFileInfo &fi, dir.entryInfoList(nameFilters, QDir::Files)) {
|
||||
const auto fis = dir.entryInfoList(nameFilters, QDir::Files);
|
||||
for (const QFileInfo &fi : fis) {
|
||||
const QByteArray file = QFile::encodeName(fi.absoluteFilePath());
|
||||
QBasicFontDatabase::addTTFile(QByteArray(), file);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ QFontEngineMultiFontConfig::QFontEngineMultiFontConfig(QFontEngine *fe, int scri
|
||||
|
||||
QFontEngineMultiFontConfig::~QFontEngineMultiFontConfig()
|
||||
{
|
||||
Q_FOREACH (FcPattern *pattern, cachedMatchPatterns) {
|
||||
for (FcPattern *pattern : qAsConst(cachedMatchPatterns)) {
|
||||
if (pattern)
|
||||
FcPatternDestroy(pattern);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ QCoreTextFontDatabase::QCoreTextFontDatabase(bool useFreeType)
|
||||
|
||||
QCoreTextFontDatabase::~QCoreTextFontDatabase()
|
||||
{
|
||||
foreach (CTFontDescriptorRef ref, m_systemFontDescriptors)
|
||||
for (CTFontDescriptorRef ref : qAsConst(m_systemFontDescriptors))
|
||||
CFRelease(ref);
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ void QCoreTextFontDatabase::removeApplicationFonts()
|
||||
if (m_applicationFonts.isEmpty())
|
||||
return;
|
||||
|
||||
foreach (const QVariant &font, m_applicationFonts) {
|
||||
for (const QVariant &font : qAsConst(m_applicationFonts)) {
|
||||
CFErrorRef error;
|
||||
if (font.canConvert(qMetaTypeId<QCFType<CGFontRef> >())) {
|
||||
CTFontManagerUnregisterGraphicsFont(font.value<QCFType<CGFontRef> >(), &error);
|
||||
|
@ -84,10 +84,9 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &
|
||||
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this);
|
||||
if (m_deviceDiscovery) {
|
||||
// scan and add already connected keyboards
|
||||
QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
foreach (const QString &device, devices) {
|
||||
const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
for (const QString &device : devices)
|
||||
addKeyboard(device);
|
||||
}
|
||||
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString)));
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString)));
|
||||
|
@ -90,10 +90,9 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif
|
||||
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this);
|
||||
if (m_deviceDiscovery) {
|
||||
// scan and add already connected keyboards
|
||||
QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
foreach (const QString &device, devices) {
|
||||
const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
for (const QString &device : devices)
|
||||
addMouse(device);
|
||||
}
|
||||
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString)));
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString)));
|
||||
|
@ -85,8 +85,8 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec
|
||||
qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery";
|
||||
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this);
|
||||
if (m_deviceDiscovery) {
|
||||
QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
foreach (const QString &device, devices)
|
||||
const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
for (const QString &device : devices)
|
||||
addDevice(device);
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
|
||||
|
@ -85,8 +85,8 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif
|
||||
qCDebug(qLcEvdevTouch) << "evdevtouch: Using device discovery";
|
||||
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this);
|
||||
if (m_deviceDiscovery) {
|
||||
QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
foreach (const QString &device, devices)
|
||||
const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
|
||||
for (const QString &device : devices)
|
||||
addDevice(device);
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
|
||||
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
|
||||
|
@ -368,7 +368,7 @@ void QKdeThemePrivate::refresh()
|
||||
|
||||
QVariant QKdeThemePrivate::readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings)
|
||||
{
|
||||
foreach (const QString &kdeDir, kdeDirs) {
|
||||
for (const QString &kdeDir : kdeDirs) {
|
||||
QSettings *settings = kdeSettings.value(kdeDir);
|
||||
if (!settings) {
|
||||
const QString kdeGlobalsPath = kdeGlobals(kdeDir, kdeVersion);
|
||||
@ -501,7 +501,7 @@ QStringList QKdeThemePrivate::kdeIconThemeSearchPaths(const QStringList &kdeDirs
|
||||
{
|
||||
QStringList paths = QGenericUnixTheme::xdgIconThemePaths();
|
||||
const QString iconPath = QStringLiteral("/share/icons");
|
||||
foreach (const QString &candidate, kdeDirs) {
|
||||
for (const QString &candidate : kdeDirs) {
|
||||
const QFileInfo fi(candidate + iconPath);
|
||||
if (fi.isDir())
|
||||
paths.append(fi.absoluteFilePath());
|
||||
@ -798,8 +798,8 @@ QStringList QGenericUnixTheme::themeNames()
|
||||
<< "MATE"
|
||||
<< "XFCE"
|
||||
<< "LXDE";
|
||||
QList<QByteArray> desktopNames = desktopEnvironment.split(':');
|
||||
Q_FOREACH (const QByteArray &desktopName, desktopNames) {
|
||||
const QList<QByteArray> desktopNames = desktopEnvironment.split(':');
|
||||
for (const QByteArray &desktopName : desktopNames) {
|
||||
if (desktopEnvironment == "KDE") {
|
||||
#ifndef QT_NO_SETTINGS
|
||||
result.push_back(QLatin1String(QKdeTheme::name));
|
||||
|
Loading…
Reference in New Issue
Block a user