Skip to content

Commit 81cd1f1

Browse files
authored
Minor optimization: emplace_back neighbors (#3086)
1 parent a078e81 commit 81cd1f1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

dlib/image_transforms/label_connected_blobs.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace dlib
2626
for (long i = -2; i <= 2; ++i)
2727
for (long j = -2; j <= 2; ++j)
2828
if (i!=0||j!=0)
29-
neighbors.push_back(point(p.x()+i,p.y()+j));
29+
neighbors.emplace_back(p.x()+i,p.y()+j);
3030
}
3131
};
3232

@@ -37,16 +37,16 @@ namespace dlib
3737
std::vector<point>& neighbors
3838
) const
3939
{
40-
neighbors.push_back(point(p.x()+1,p.y()+1));
41-
neighbors.push_back(point(p.x()+1,p.y() ));
42-
neighbors.push_back(point(p.x()+1,p.y()-1));
40+
neighbors.emplace_back(p.x()+1,p.y()+1);
41+
neighbors.emplace_back(p.x()+1,p.y() );
42+
neighbors.emplace_back(p.x()+1,p.y()-1);
4343

44-
neighbors.push_back(point(p.x(),p.y()+1));
45-
neighbors.push_back(point(p.x(),p.y()-1));
44+
neighbors.emplace_back(p.x(),p.y()+1);
45+
neighbors.emplace_back(p.x(),p.y()-1);
4646

47-
neighbors.push_back(point(p.x()-1,p.y()+1));
48-
neighbors.push_back(point(p.x()-1,p.y() ));
49-
neighbors.push_back(point(p.x()-1,p.y()-1));
47+
neighbors.emplace_back(p.x()-1,p.y()+1);
48+
neighbors.emplace_back(p.x()-1,p.y() );
49+
neighbors.emplace_back(p.x()-1,p.y()-1);
5050
}
5151
};
5252

@@ -57,10 +57,10 @@ namespace dlib
5757
std::vector<point>& neighbors
5858
) const
5959
{
60-
neighbors.push_back(point(p.x()+1,p.y()));
61-
neighbors.push_back(point(p.x()-1,p.y()));
62-
neighbors.push_back(point(p.x(),p.y()+1));
63-
neighbors.push_back(point(p.x(),p.y()-1));
60+
neighbors.emplace_back(p.x()+1,p.y());
61+
neighbors.emplace_back(p.x()-1,p.y());
62+
neighbors.emplace_back(p.x(),p.y()+1);
63+
neighbors.emplace_back(p.x(),p.y()-1);
6464
}
6565
};
6666

0 commit comments

Comments
 (0)