Convert a few sizeof(array)/sizeof(element0) fors to range fors
Increases readability Change-Id: I81ea915517fd2cd6bc2780f37ba8d8097c63f44b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
74a33df026
commit
3afe4a402c
@ -746,7 +746,6 @@ bool QSettingsPrivate::iniUnescapedStringList(const QByteArray &str, int from, i
|
||||
{ '\'', '\'' },
|
||||
{ '\\', '\\' }
|
||||
};
|
||||
static const int numEscapeCodes = sizeof(escapeCodes) / sizeof(escapeCodes[0]);
|
||||
|
||||
bool isStringList = false;
|
||||
bool inQuotedString = false;
|
||||
@ -770,9 +769,9 @@ StNormal:
|
||||
goto end;
|
||||
|
||||
ch = str.at(i++);
|
||||
for (int j = 0; j < numEscapeCodes; ++j) {
|
||||
if (ch == escapeCodes[j][0]) {
|
||||
stringResult += QLatin1Char(escapeCodes[j][1]);
|
||||
for (const auto &escapeCode : escapeCodes) {
|
||||
if (ch == escapeCode[0]) {
|
||||
stringResult += QLatin1Char(escapeCode[1]);
|
||||
goto StNormal;
|
||||
}
|
||||
}
|
||||
|
@ -100,15 +100,15 @@ bool qdbus_loadLibDBus()
|
||||
};
|
||||
|
||||
lib->unload();
|
||||
for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) {
|
||||
for (uint j = 0; j < sizeof(baseNames) / sizeof(baseNames[0]); ++j) {
|
||||
for (const int majorversion : majorversions) {
|
||||
for (const QString &baseName : baseNames) {
|
||||
#ifdef Q_OS_WIN
|
||||
QString suffix;
|
||||
if (majorversions[i] != -1)
|
||||
suffix = QString::number(- majorversions[i]); // negative so it prepends the dash
|
||||
lib->setFileName(baseNames[j] + suffix);
|
||||
if (majorversion != -1)
|
||||
suffix = QString::number(- majorversion); // negative so it prepends the dash
|
||||
lib->setFileName(baseName + suffix);
|
||||
#else
|
||||
lib->setFileNameAndVersion(baseNames[j], majorversions[i]);
|
||||
lib->setFileNameAndVersion(baseName, majorversion);
|
||||
#endif
|
||||
if (lib->load() && lib->resolve("dbus_connection_open_private"))
|
||||
return true;
|
||||
|
@ -222,8 +222,6 @@ static const int qt_windowsConversion[][2] = {
|
||||
{DMPAPER_PENV_10_ROTATED, DMPAPER_PENV_10} // Is = DMPAPER_LAST, use as loop terminator
|
||||
};
|
||||
|
||||
static const int windowsConversionCount = int(sizeof(qt_windowsConversion) / sizeof(qt_windowsConversion[0]));
|
||||
|
||||
// Standard sizes data
|
||||
struct StandardPageSize {
|
||||
QPageSize::PageSizeId id;
|
||||
@ -423,9 +421,9 @@ static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = 0)
|
||||
if (windowsId <= DMPAPER_NONE || windowsId > DMPAPER_LAST)
|
||||
return QPageSize::Custom;
|
||||
// Check if one of the unsupported values, convert to valid value if is
|
||||
for (int i = 0; i < windowsConversionCount; ++i) {
|
||||
if (qt_windowsConversion[i][0] == windowsId) {
|
||||
windowsId = qt_windowsConversion[i][1];
|
||||
for (const auto &it : qt_windowsConversion) {
|
||||
if (it[0] == windowsId) {
|
||||
windowsId = it[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3241,12 +3241,12 @@ QVector<int> QRhiVulkan::supportedSampleCounts() const
|
||||
VkSampleCountFlags stencil = limits->framebufferStencilSampleCounts;
|
||||
QVector<int> result;
|
||||
|
||||
for (size_t i = 0; i < sizeof(qvk_sampleCounts) / sizeof(qvk_sampleCounts[0]); ++i) {
|
||||
if ((color & qvk_sampleCounts[i].mask)
|
||||
&& (depth & qvk_sampleCounts[i].mask)
|
||||
&& (stencil & qvk_sampleCounts[i].mask))
|
||||
for (const auto &qvk_sampleCount : qvk_sampleCounts) {
|
||||
if ((color & qvk_sampleCount.mask)
|
||||
&& (depth & qvk_sampleCount.mask)
|
||||
&& (stencil & qvk_sampleCount.mask))
|
||||
{
|
||||
result.append(qvk_sampleCounts[i].count);
|
||||
result.append(qvk_sampleCount.count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3263,9 +3263,9 @@ VkSampleCountFlagBits QRhiVulkan::effectiveSampleCount(int sampleCount)
|
||||
return VK_SAMPLE_COUNT_1_BIT;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sizeof(qvk_sampleCounts) / sizeof(qvk_sampleCounts[0]); ++i) {
|
||||
if (qvk_sampleCounts[i].count == sampleCount)
|
||||
return qvk_sampleCounts[i].mask;
|
||||
for (const auto &qvk_sampleCount : qvk_sampleCounts) {
|
||||
if (qvk_sampleCount.count == sampleCount)
|
||||
return qvk_sampleCount.mask;
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
|
@ -498,12 +498,12 @@ QVector<int> QVulkanWindow::supportedSampleCounts()
|
||||
VkSampleCountFlags depth = limits->framebufferDepthSampleCounts;
|
||||
VkSampleCountFlags stencil = limits->framebufferStencilSampleCounts;
|
||||
|
||||
for (size_t i = 0; i < sizeof(qvk_sampleCounts) / sizeof(qvk_sampleCounts[0]); ++i) {
|
||||
if ((color & qvk_sampleCounts[i].mask)
|
||||
&& (depth & qvk_sampleCounts[i].mask)
|
||||
&& (stencil & qvk_sampleCounts[i].mask))
|
||||
for (const auto &qvk_sampleCount : qvk_sampleCounts) {
|
||||
if ((color & qvk_sampleCount.mask)
|
||||
&& (depth & qvk_sampleCount.mask)
|
||||
&& (stencil & qvk_sampleCount.mask))
|
||||
{
|
||||
result.append(qvk_sampleCounts[i].count);
|
||||
result.append(qvk_sampleCount.count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -547,9 +547,9 @@ void QVulkanWindow::setSampleCount(int sampleCount)
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sizeof(qvk_sampleCounts) / sizeof(qvk_sampleCounts[0]); ++i) {
|
||||
if (qvk_sampleCounts[i].count == sampleCount) {
|
||||
d->sampleCount = qvk_sampleCounts[i].mask;
|
||||
for (const auto &qvk_sampleCount : qvk_sampleCounts) {
|
||||
if (qvk_sampleCount.count == sampleCount) {
|
||||
d->sampleCount = qvk_sampleCount.mask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1339,14 +1339,13 @@ void QHttp2ProtocolHandler::markAsReset(quint32 streamID)
|
||||
quint32 QHttp2ProtocolHandler::popStreamToResume()
|
||||
{
|
||||
quint32 streamID = connectionStreamID;
|
||||
const int nQ = sizeof suspendedStreams / sizeof suspendedStreams[0];
|
||||
using QNR = QHttpNetworkRequest;
|
||||
const QNR::Priority ranks[nQ] = {QNR::HighPriority,
|
||||
QNR::NormalPriority,
|
||||
QNR::LowPriority};
|
||||
const QNR::Priority ranks[] = {QNR::HighPriority,
|
||||
QNR::NormalPriority,
|
||||
QNR::LowPriority};
|
||||
|
||||
for (int i = 0; i < nQ; ++i) {
|
||||
auto &queue = suspendedStreams[ranks[i]];
|
||||
for (const QNR::Priority rank : ranks) {
|
||||
auto &queue = suspendedStreams[rank];
|
||||
auto it = queue.begin();
|
||||
for (; it != queue.end(); ++it) {
|
||||
if (!activeStreams.contains(*it))
|
||||
@ -1367,9 +1366,7 @@ quint32 QHttp2ProtocolHandler::popStreamToResume()
|
||||
|
||||
void QHttp2ProtocolHandler::removeFromSuspended(quint32 streamID)
|
||||
{
|
||||
const int nQ = sizeof suspendedStreams / sizeof suspendedStreams[0];
|
||||
for (int i = 0; i < nQ; ++i) {
|
||||
auto &q = suspendedStreams[i];
|
||||
for (auto &q : suspendedStreams) {
|
||||
q.erase(std::remove(q.begin(), q.end(), streamID), q.end());
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,6 @@
|
||||
#include "qedidparser_p.h"
|
||||
#include "qedidvendortable_p.h"
|
||||
|
||||
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
||||
|
||||
#define EDID_DESCRIPTOR_ALPHANUMERIC_STRING 0xfe
|
||||
#define EDID_DESCRIPTOR_PRODUCT_NAME 0xfc
|
||||
#define EDID_DESCRIPTOR_SERIAL_NUMBER 0xff
|
||||
@ -139,9 +137,9 @@ bool QEdidParser::parse(const QByteArray &blob)
|
||||
manufacturer = m_vendorCache.value(pnpIdString);
|
||||
if (manufacturer.isEmpty()) {
|
||||
// Find the manufacturer from the vendor lookup table
|
||||
for (size_t i = 0; i < ARRAY_LENGTH(q_edidVendorTable); i++) {
|
||||
if (strncmp(q_edidVendorTable[i].id, pnpId, 3) == 0) {
|
||||
manufacturer = QString::fromUtf8(q_edidVendorTable[i].name);
|
||||
for (const auto &vendor : q_edidVendorTable) {
|
||||
if (strncmp(vendor.id, pnpId, 3) == 0) {
|
||||
manufacturer = QString::fromUtf8(vendor.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user