summaryrefslogtreecommitdiffstats
path: root/src/proj_pt.h
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-10-13 13:30:32 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-10-13 13:30:32 +0000
commit0435dcd7c3fd5f4ee19e91fca2162b9d68687dc5 (patch)
tree9def2ade153c1cd89c9c45ce44db8b8c585620e8 /src/proj_pt.h
parentFix crash on filters (diff)
downloadinkscape-0435dcd7c3fd5f4ee19e91fca2162b9d68687dc5.tar.gz
inkscape-0435dcd7c3fd5f4ee19e91fca2162b9d68687dc5.zip
operators should return by value
Diffstat (limited to 'src/proj_pt.h')
-rw-r--r--src/proj_pt.h48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/proj_pt.h b/src/proj_pt.h
index fb6f52ab8..9b7a17abc 100644
--- a/src/proj_pt.h
+++ b/src/proj_pt.h
@@ -51,32 +51,32 @@ public:
/*** For convenience, we define addition/subtraction etc. as "affine" operators (i.e.,
the result for finite points is the same as if the affine points were added ***/
inline Pt2 &operator+(Pt2 &rhs) const {
- Pt2 *result = new Pt2 (*this);
- result->normalize();
+ Pt2 result (*this);
+ result.normalize();
rhs.normalize();
for ( unsigned i = 0 ; i < 2 ; ++i ) {
- result->pt[i] += rhs.pt[i];
+ result.pt[i] += rhs.pt[i];
}
- return *result;
+ return result;
}
inline Pt2 &operator-(Pt2 &rhs) const {
- Pt2 *result = new Pt2 (*this);
- result->normalize();
+ Pt2 result (*this);
+ result.normalize();
rhs.normalize();
for ( unsigned i = 0 ; i < 2 ; ++i ) {
- result->pt[i] -= rhs.pt[i];
+ result.pt[i] -= rhs.pt[i];
}
- return *result;
+ return result;
}
inline Pt2 &operator*(double const s) const {
- Pt2 *result = new Pt2 (*this);
- result->normalize();
+ Pt2 result (*this);
+ result.normalize();
for ( unsigned i = 0 ; i < 2 ; ++i ) {
- result->pt[i] *= s;
+ result.pt[i] *= s;
}
- return *result;
+ return result;
}
void normalize();
@@ -108,32 +108,32 @@ public:
/*** For convenience, we define addition/subtraction etc. as "affine" operators (i.e.,
the result for finite points is the same as if the affine points were added ***/
inline Pt3 &operator+(Pt3 &rhs) const {
- Pt3 *result = new Pt3 (*this);
- result->normalize();
+ Pt3 result(*this);
+ result.normalize();
rhs.normalize();
for ( unsigned i = 0 ; i < 3 ; ++i ) {
- result->pt[i] += rhs.pt[i];
+ result.pt[i] += rhs.pt[i];
}
- return *result;
+ return result;
}
inline Pt3 &operator-(Pt3 &rhs) const {
- Pt3 *result = new Pt3 (*this);
- result->normalize();
+ Pt3 result (*this);
+ result.normalize();
rhs.normalize();
for ( unsigned i = 0 ; i < 3 ; ++i ) {
- result->pt[i] -= rhs.pt[i];
+ result.pt[i] -= rhs.pt[i];
}
- return *result;
+ return result;
}
inline Pt3 &operator*(double const s) const {
- Pt3 *result = new Pt3 (*this);
- result->normalize();
+ Pt3 result (*this);
+ result.normalize();
for ( unsigned i = 0 ; i < 3 ; ++i ) {
- result->pt[i] *= s;
+ result.pt[i] *= s;
}
- return *result;
+ return result;
}
inline double operator[] (unsigned int index) const {