Skip to content

Commit da2ed88

Browse files
committed
Use const auto & in a few for loops that were not doing it.
Could help with compiler optimizations and thus performance.
1 parent a31a89a commit da2ed88

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/draw.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void GraphicsWindow::Selection::Draw(bool isHovered, Canvas *canvas) {
7171
auto it = std::unique(refs.begin(), refs.end(),
7272
[](Vector a, Vector b) { return a.Equals(b); });
7373
refs.erase(it, refs.end());
74-
for(Vector p : refs) {
74+
for(const Vector &p : refs) {
7575
canvas->DrawLine(topLeft, p, hcsEmphasis);
7676
}
7777
}

src/export.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ void SolveSpaceUI::ExportMeshAsVrmlTo(FILE *f, const Platform::Path &filename, S
11961196
}
11971197

11981198
// Output all the vertices.
1199-
for(auto sp : spl.l) {
1199+
for(const auto &sp : spl.l) {
12001200
fprintf(f, " %f %f %f,\n",
12011201
sp.p.x / SS.exportScale,
12021202
sp.p.y / SS.exportScale,

src/file.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void SolveSpaceUI::SaveUsingTable(const Platform::Path &filename, int type) {
261261
[](std::pair<EntityKey, EntityId> &a, std::pair<EntityKey, EntityId> &b) {
262262
return a.second.v < b.second.v;
263263
});
264-
for(auto it : sorted) {
264+
for(const auto &it : sorted) {
265265
fprintf(fh, " %d %08x %d\n",
266266
it.second.v, it.first.input.v, it.first.copyNumber);
267267
}

src/graphicswin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ void GraphicsWindow::LoopOverPoints(const std::vector<Entity *> &entities,
592592
for(Constraint *c : constraints) {
593593
std::vector<Vector> refs;
594594
c->GetReferencePoints(camera, &refs);
595-
for(Vector p : refs) {
595+
for(const Vector &p : refs) {
596596
HandlePointForZoomToFit(p, pmax, pmin, wmin, usePerspective, camera);
597597
}
598598
}

src/render/render2d.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void SurfaceRenderer::OutputInPaintOrder() {
354354
mp.Clear();
355355
}
356356

357-
for(auto eit : edges) {
357+
for(const auto &eit : edges) {
358358
hStroke hcs = eit.first;
359359
const SEdgeList &el = eit.second;
360360

src/srf/boolean.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static void FindVertsOnCurve(List<SInter> *l, const SCurve *curve, SShell *sh) {
3939
Vector amax, amin;
4040
curve->GetAxisAlignedBounding(&amax, &amin);
4141

42-
for(auto sc : sh->curve) {
42+
for(const auto &sc : sh->curve) {
4343
if(!sc.isExact) continue;
4444

4545
Vector cmax, cmin;
@@ -157,7 +157,7 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB,
157157
// Now add any vertex that is on this segment
158158
const Vector lineStart = prev.p;
159159
const Vector lineDirection = (p->p).Minus(prev.p);
160-
for(auto vtx : vertpts) {
160+
for(const auto &vtx : vertpts) {
161161
double t = (vtx.p.Minus(lineStart)).DivProjected(lineDirection);
162162
if((0.0 < t) && (t < 1.0)) {
163163
il.Add(&vtx);

0 commit comments

Comments
 (0)