Pass expensive to copy object by reference to const.

This commit is contained in:
Roman Telezhynskyi 2024-02-21 13:38:02 +02:00
parent 2f53e38ad7
commit ed7f357a3c
9 changed files with 20 additions and 20 deletions

View File

@ -664,7 +664,7 @@ public:
delete item;
}
void applyExtrusion() override;
void addVertex(DRW_Vertex2D v)
void addVertex(const DRW_Vertex2D &v)
{
auto *vert = new DRW_Vertex2D();
vert->x = v.x;
@ -917,7 +917,7 @@ public:
for (DRW_Vertex *item : vertlist)
delete item;
}
void addVertex(DRW_Vertex v)
void addVertex(const DRW_Vertex& v)
{
auto *vert = new DRW_Vertex();
vert->basePoint.x = v.basePoint.x;

View File

@ -1831,7 +1831,7 @@ void DRW_Header::write(const std::unique_ptr<dxfWriter> &writer, DRW::Version ve
#endif
}
void DRW_Header::addDouble(std::string key, double value, int code)
void DRW_Header::addDouble(const std::string &key, double value, int code)
{
curr = new DRW_Variant();
curr->addDouble(value);
@ -1839,7 +1839,7 @@ void DRW_Header::addDouble(std::string key, double value, int code)
vars[key] = curr;
}
void DRW_Header::addInt(std::string key, int value, int code)
void DRW_Header::addInt(const std::string &key, int value, int code)
{
curr = new DRW_Variant();
curr->addInt(value);
@ -1847,7 +1847,7 @@ void DRW_Header::addInt(std::string key, int value, int code)
vars[key] = curr;
}
void DRW_Header::addStr(std::string key, const std::string &value, int code)
void DRW_Header::addStr(const std::string &key, const std::string &value, int code)
{
curr = new DRW_Variant();
curr->addString(value);
@ -1855,7 +1855,7 @@ void DRW_Header::addStr(std::string key, const std::string &value, int code)
vars[key] = curr;
}
void DRW_Header::addCoord(std::string key, const DRW_Coord &value, int code)
void DRW_Header::addCoord(const std::string &key, const DRW_Coord &value, int code)
{
curr = new DRW_Variant();
curr->addCoord(value);

View File

@ -107,10 +107,10 @@ public:
return *this;
}
void addDouble(std::string key, double value, int code);
void addInt(std::string key, int value, int code);
void addStr(std::string key, const std::string &value, int code);
void addCoord(std::string key, const DRW_Coord &value, int code);
void addDouble(const std::string &key, double value, int code);
void addInt(const std::string &key, int value, int code);
void addStr(const std::string &key, const std::string &value, int code);
void addCoord(const std::string &key, const DRW_Coord &value, int code);
auto getComments() const -> std::string { return comments; }
void write(const std::unique_ptr<dxfWriter>& writer, DRW::Version ver);
void addComment(const std::string &c);

View File

@ -105,7 +105,7 @@ auto dxfWriter::writeUtf8Caps(int code, const std::string &text) -> bool
return writeString(code, t);
}
auto dxfWriterBinary::writeString(int code, std::string text) -> bool
auto dxfWriterBinary::writeString(int code, const std::string &text) -> bool
{
char bufcode[2];
bufcode[0] = static_cast<char>(code & 0xFF);
@ -227,7 +227,7 @@ dxfWriterAscii::dxfWriterAscii(std::ofstream *stream):dxfWriter(stream){
filestr->precision(16);
}
auto dxfWriterAscii::writeString(int code, std::string text) -> bool
auto dxfWriterAscii::writeString(int code, const std::string &text) -> bool
{
// *filestr << code << std::endl << text << std::endl ;
filestr->width(3);

View File

@ -25,7 +25,7 @@ public:
}
virtual ~dxfWriter() = default;
virtual auto writeString(int code, std::string text) -> bool = 0;
virtual auto writeString(int code, const std::string &text) -> bool = 0;
auto writeUtf8String(int code, const std::string &text) -> bool;
auto writeUtf8Caps(int code, const std::string &text) -> bool;
auto fromUtf8String(const std::string &t) -> std::string { return encoder.fromUtf8(t); }
@ -52,7 +52,7 @@ public:
using dxfWriter::dxfWriter;
virtual ~dxfWriterBinary() = default;
virtual auto writeString(int code, std::string text) -> bool override;
virtual auto writeString(int code, const std::string &text) -> bool override;
virtual auto writeInt16(int code, int data) -> bool override;
virtual auto writeInt32(int code, int data) -> bool override;
virtual auto writeInt64(int code, unsigned long long int data) -> bool override;
@ -65,7 +65,7 @@ class dxfWriterAscii final : public dxfWriter
public:
explicit dxfWriterAscii(std::ofstream *stream);
virtual ~dxfWriterAscii() = default;
virtual auto writeString(int code, std::string text) -> bool override;
virtual auto writeString(int code, const std::string &text) -> bool override;
virtual auto writeInt16(int code, int data) -> bool override;
virtual auto writeInt32(int code, int data) -> bool override;
virtual auto writeInt64(int code, unsigned long long int data) -> bool override;

View File

@ -1685,7 +1685,7 @@ auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef
return nullptr; // not exist in acad 12
}
auto dxfRW::writeBlockRecord(std::string name) -> bool
auto dxfRW::writeBlockRecord(const std::string &name) -> bool
{
if (version > DRW::AC1009)
{

View File

@ -69,7 +69,7 @@ public:
auto writeLWPolyline(DRW_LWPolyline *ent) -> bool;
auto writePolyline(DRW_Polyline *ent) -> bool;
auto writeSpline(DRW_Spline *ent) -> bool;
auto writeBlockRecord(std::string name) -> bool;
auto writeBlockRecord(const std::string &name) -> bool;
auto writeBlock(DRW_Block *bk) -> bool;
auto writeInsert(DRW_Insert *ent) -> bool;
auto writeMText(DRW_MText *ent) -> bool;

View File

@ -90,7 +90,7 @@ class VSplinePointData final : public QSharedData
{
public:
VSplinePointData() = default;
VSplinePointData(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
VSplinePointData(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
qreal length1, const QString &length1F, qreal length2, const QString &length2F);
VSplinePointData(const VSplinePointData &point);
~VSplinePointData() = default;
@ -119,7 +119,7 @@ private:
};
//---------------------------------------------------------------------------------------------------------------------
inline VSplinePointData::VSplinePointData(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2,
inline VSplinePointData::VSplinePointData(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2,
const QString &angle2F, qreal length1, const QString &length1F, qreal length2,
const QString &length2F)
: pSpline(pSpline),

View File

@ -178,7 +178,7 @@ void TST_VAbstractCurve::CurveIntersectLine_data()
QTest::addColumn<QVector<QPointF>>("intersections");
QTest::addColumn<QLineF>("line");
auto ASSERT_TEST_CASE = [](const char *title, const QString &input, const QString &output, QLineF line)
auto ASSERT_TEST_CASE = [](const char *title, const QString &input, const QString &output, const QLineF &line)
{
QVector<QPointF> const points = AbstractTest::VectorFromJson<QPointF>(input);
QVector<QPointF> const intersections = AbstractTest::VectorFromJson<QPointF>(output);