summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel/qprinterinfo.cpp
diff options
context:
space:
mode:
authorSérgio Martins <sergio.martins@kdab.com>2015-06-23 16:18:12 +0100
committerSérgio Martins <sergio.martins@kdab.com>2015-06-27 11:48:36 +0000
commit507b6b3e4bcef3ef280944f3956b7f32ed86985b (patch)
tree4605884475983e49e985cff2cd7e4149b780a6b1 /src/printsupport/kernel/qprinterinfo.cpp
parenta5306c35d1cf1e471e2a073aa1ba279081ea47ee (diff)
Use QList::reserve(), reduces reallocations
Change-Id: I9f218bdd65a97ad9c867b695f3ba27ab64a54d2a Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/printsupport/kernel/qprinterinfo.cpp')
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index ad488a10ed..1be574891b 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -316,7 +316,9 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::PaperSize> list;
- foreach (const QPageSize &pageSize, d->m_printDevice.supportedPageSizes())
+ const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
+ list.reserve(supportedPageSizes.size());
+ foreach (const QPageSize &pageSize, supportedPageSizes)
list.append(QPrinter::PaperSize(pageSize.id()));
return list;
}
@@ -336,7 +338,9 @@ QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const
{
Q_D(const QPrinterInfo);
QList<QPair<QString, QSizeF> > list;
- foreach (const QPageSize &pageSize, d->m_printDevice.supportedPageSizes())
+ const QList<QPageSize> supportedPageSizes = d->m_printDevice.supportedPageSizes();
+ list.reserve(supportedPageSizes.size());
+ foreach (const QPageSize &pageSize, supportedPageSizes)
list.append(qMakePair(pageSize.name(), pageSize.size(QPageSize::Millimeter)));
return list;
}
@@ -376,7 +380,9 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::DuplexMode> list;
- foreach (QPrint::DuplexMode mode, d->m_printDevice.supportedDuplexModes())
+ const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
+ list.reserve(supportedDuplexModes.size());
+ foreach (QPrint::DuplexMode mode, supportedDuplexModes)
list << QPrinter::DuplexMode(mode);
return list;
}
@@ -416,7 +422,9 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
QList<QPrinterInfo> list;
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps) {
- foreach (const QString &id, ps->availablePrintDeviceIds())
+ const QStringList availablePrintDeviceIds = ps->availablePrintDeviceIds();
+ list.reserve(availablePrintDeviceIds.size());
+ foreach (const QString &id, availablePrintDeviceIds)
list.append(QPrinterInfo(id));
}
return list;