Refactoring.

Avoid unnecessary copy by using a "const" reference.
This commit is contained in:
Roman Telezhynskyi 2024-04-16 17:12:32 +03:00
parent 0080ce8ef5
commit 1ddb07f2ee
5 changed files with 12 additions and 12 deletions

View File

@ -95,7 +95,7 @@ auto LinesToString(const QVector<QLineF> &lines) -> QString
{
QStringList l;
l.reserve(lines.size());
for (auto line : lines)
for (const auto &line : lines)
{
l.append(LineToString(line));
}

View File

@ -611,7 +611,7 @@ auto VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows, qreal
{
QPainterPath path;
for (auto arrow : arrows)
for (const auto &arrow : arrows)
{
if (not arrow.first.isNull() && not arrow.second.isNull())
{

View File

@ -44,7 +44,7 @@ namespace
auto PassmarkShapeToJson(const QVector<QLineF> &shape) -> QJsonArray
{
QJsonArray shapeArray;
for (auto line : shape)
for (const auto &line : shape)
{
QJsonObject const lineObject{
{"type", "QLineF"},

View File

@ -51,7 +51,7 @@ auto SourceToObjects(const QVector<SourceItem> &source) -> QVector<quint32>
QVector<quint32> ids;
ids.reserve(source.size());
for (auto s : source)
for (const auto &s : source)
{
ids.append(s.id);
}

View File

@ -35,8 +35,8 @@
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_VPoster::TST_VPoster(QObject *parent) :
QObject(parent)
TST_VPoster::TST_VPoster(QObject *parent)
: QObject(parent)
{
}
@ -59,7 +59,7 @@ void TST_VPoster::BigPoster()
QCOMPARE(poster.size(), 12);
for (auto p : poster)
for (const auto &p : poster)
{
QCOMPARE(p.rect.size(), PageRect(printer).size());
}
@ -89,8 +89,8 @@ auto TST_VPoster::PageRect(const QPrinter &printer) const -> QRect
// we can't use method pageRect(QPrinter::Point). Our dpi different can be different.
// We convert value yourself to pixels.
const QRectF rect = printer.pageRect(QPrinter::Millimeter);
QRect pageRect(qFloor(ToPixel(rect.x())), qFloor(ToPixel(rect.y())),
qFloor(ToPixel(rect.width())), qFloor(ToPixel(rect.height())));
QRect pageRect(qFloor(ToPixel(rect.x())), qFloor(ToPixel(rect.y())), qFloor(ToPixel(rect.width())),
qFloor(ToPixel(rect.height())));
return pageRect;
}