summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2013-08-03 20:57:37 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2013-08-03 20:57:37 +0000
commit2580137d7c69ba5752ca7ce698d6cf104ff7f00c (patch)
tree0e0625f54a21c0390f5b5ec1415bfcaf0e7c00f4 /src
parentfix initialization (diff)
downloadinkscape-2580137d7c69ba5752ca7ce698d6cf104ff7f00c.tar.gz
inkscape-2580137d7c69ba5752ca7ce698d6cf104ff7f00c.zip
fix small "performance" issues (cppcheck)
(bzr r12461)
Diffstat (limited to 'src')
-rw-r--r--src/livarot/Path.cpp16
-rw-r--r--src/livarot/PathConversion.cpp21
-rw-r--r--src/livarot/PathCutting.cpp6
-rw-r--r--src/livarot/PathOutline.cpp3
-rw-r--r--src/livarot/ShapeRaster.cpp6
-rw-r--r--src/livarot/ShapeSweep.cpp6
6 files changed, 22 insertions, 36 deletions
diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp
index 88d397864..68891e4aa 100644
--- a/src/livarot/Path.cpp
+++ b/src/livarot/Path.cpp
@@ -28,7 +28,7 @@ Path::Path()
Path::~Path()
{
- for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) {
+ for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) {
delete *i;
}
}
@@ -37,7 +37,7 @@ Path::~Path()
void Path::Affiche()
{
std::cout << "path: " << descr_cmd.size() << " commands." << std::endl;
- for (std::vector<PathDescr*>::const_iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) {
+ for (std::vector<PathDescr*>::const_iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) {
(*i)->dump(std::cout);
std::cout << std::endl;
}
@@ -47,7 +47,7 @@ void Path::Affiche()
void Path::Reset()
{
- for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) {
+ for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) {
delete *i;
}
@@ -61,7 +61,7 @@ void Path::Copy(Path * who)
{
ResetPoints();
- for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) {
+ for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) {
delete *i;
}
@@ -69,7 +69,7 @@ void Path::Copy(Path * who)
for (std::vector<PathDescr*>::const_iterator i = who->descr_cmd.begin();
i != who->descr_cmd.end();
- i++)
+ ++i)
{
descr_cmd.push_back((*i)->clone());
}
@@ -496,9 +496,9 @@ void Path::PolylineBoundingBox(double &l, double &t, double &r, double &b)
std::vector<path_lineto>::const_iterator i = pts.begin();
l = r = i->p[Geom::X];
t = b = i->p[Geom::Y];
- i++;
+ ++i;
- for (; i != pts.end(); i++) {
+ for (; i != pts.end(); ++i) {
r = std::max(r, i->p[Geom::X]);
l = std::min(l, i->p[Geom::X]);
b = std::max(b, i->p[Geom::Y]);
@@ -701,7 +701,7 @@ void Path::PointAndTangentAt(int piece, double at, Geom::Point &pos, Geom::Point
void Path::Transform(const Geom::Affine &trans)
{
- for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) {
+ for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); ++i) {
(*i)->transform(trans);
}
}
diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp
index ed5f03f80..8d36dca4c 100644
--- a/src/livarot/PathConversion.cpp
+++ b/src/livarot/PathConversion.cpp
@@ -119,15 +119,12 @@ void Path::ConvertWithBackData(double treshhold)
if ( nbInterm >= 1 ) {
Geom::Point bx = curX;
- Geom::Point cx = curX;
- Geom::Point dx = curX;
+ Geom::Point dx = nData->p;
+ Geom::Point cx = 2 * bx - dx;
- dx = nData->p;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- cx = 2 * bx - dx;
-
for (int k = 0; k < nbInterm - 1; k++) {
bx = cx;
cx = dx;
@@ -323,15 +320,12 @@ void Path::Convert(double treshhold)
RecBezierTo(midX, curX, nextX, treshhold, 8);
} else if ( nbInterm > 1 ) {
Geom::Point bx = curX;
- Geom::Point cx = curX;
- Geom::Point dx = curX;
+ Geom::Point dx = nData->p;
+ Geom::Point cx = 2 * bx - dx;
- dx = nData->p;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- cx = 2 * bx - dx;
-
for (int k = 0; k < nbInterm - 1; k++) {
bx = cx;
cx = dx;
@@ -565,15 +559,12 @@ void Path::ConvertEvenLines(double treshhold)
RecBezierTo(midX, curX, nextX, treshhold, 8, 4 * treshhold);
} else if ( nbInterm > 1 ) {
Geom::Point bx = curX;
- Geom::Point cx = curX;
- Geom::Point dx = curX;
+ Geom::Point dx = nData->p;
+ Geom::Point cx = 2 * bx - dx;
- dx = nData->p;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- cx = 2 * bx - dx;
-
for (int k = 0; k < nbInterm - 1; k++) {
bx = cx;
cx = dx;
diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp
index 848d8daa8..3ce907bf3 100644
--- a/src/livarot/PathCutting.cpp
+++ b/src/livarot/PathCutting.cpp
@@ -482,7 +482,7 @@ double Path::Length()
Geom::Point lastP = pts[0].p;
double len = 0;
- for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
+ for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) {
if ( i->isMoveTo != polyline_moveto ) {
len += Geom::L2(i->p - lastP);
@@ -505,7 +505,7 @@ double Path::Surface()
Geom::Point lastP = lastM;
double surf = 0;
- for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
+ for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) {
if ( i->isMoveTo == polyline_moveto ) {
surf += Geom::cross(lastM - lastP, lastM);
@@ -900,7 +900,7 @@ Path::cut_position* Path::CurvilignToPosition(int nbCv, double *cvAbs, int &nbCu
Geom::Point lastM = pts[0].p;
Geom::Point lastP = lastM;
- for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
+ for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) {
if ( i->isMoveTo == polyline_moveto ) {
diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index 7f8853e31..3b5ce79f9 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -709,9 +709,8 @@ void Path::SubContractOutline(int off, int num_pd,
} else if (nbInterm > 1) {
Geom::Point bx=curX;
Geom::Point cx=curX;
- Geom::Point dx=curX;
+ Geom::Point dx=nData->p;
- dx = nData->p;
TangentOnBezAt (0.0, curX, *nData, *nBData, false, stPos, stTgt, stTle, stRad);
stNor=stTgt.cw();
diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp
index b7b087fba..4c5bdc1ac 100644
--- a/src/livarot/ShapeRaster.cpp
+++ b/src/livarot/ShapeRaster.cpp
@@ -1131,8 +1131,7 @@ void Shape::Scan(float &pos, int &curP, float to, AlphaLigne *line, bool exact,
int curPt = curP;
while ( curPt < numberOfPoints() && getPoint(curPt).x[1] <= to ) {
- int nPt = -1;
- nPt = curPt++;
+ int nPt = curPt++;
int nbUp;
int nbDn;
@@ -1435,8 +1434,7 @@ void Shape::QuickScan(float &pos, int &curP, float to, FillRule directed, BitLig
int curPt = curP;
while ( curPt < numberOfPoints() && getPoint(curPt).x[1] <= to ) {
- int nPt = -1;
- nPt = curPt++;
+ int nPt = curPt++;
int nbUp;
int nbDn;
diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp
index c2fd83e31..ff58b4a71 100644
--- a/src/livarot/ShapeSweep.cpp
+++ b/src/livarot/ShapeSweep.cpp
@@ -252,8 +252,7 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert)
Geom::Point rPtX;
rPtX[0]= Round (ptX[0]);
rPtX[1]= Round (ptX[1]);
- int lastPointNo = -1;
- lastPointNo = AddPoint (rPtX);
+ int lastPointNo = AddPoint (rPtX);
pData[lastPointNo].rx = rPtX;
if (rPtX[1] > lastChange)
@@ -1053,8 +1052,7 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID)
Geom::Point rPtX;
rPtX[0]= Round (ptX[0]);
rPtX[1]= Round (ptX[1]);
- int lastPointNo = -1;
- lastPointNo = AddPoint (rPtX);
+ int lastPointNo = AddPoint (rPtX);
pData[lastPointNo].rx = rPtX;
if (rPtX[1] > lastChange)