Skip to content

Commit e734e20

Browse files
committed
branch prediction kinda
1 parent 756dcd6 commit e734e20

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/set_intersection/intersect.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ void linear_intersect(InputIterator1 begin1, InputIterator1 end1,
1313
InputIterator2 begin2, InputIterator2 end2,
1414
OutputIterator out)
1515
{
16-
16+
if ( (end2 - begin2) > (end1 - begin1) )
17+
{
18+
// why in the world would i do this?
19+
// hmmmmmmm.......... !
20+
std::swap(begin1, begin2);
21+
std::swap(end1, end2);
22+
}
1723
while (begin1 != end1 && begin2 != end2)
1824
{
1925
if (*begin1 < *begin2)
@@ -37,6 +43,13 @@ void linear_intersect(InputIterator1 begin1, InputIterator1 end1,
3743
InputIterator2 begin2, InputIterator2 end2,
3844
OutputIterator out, Comparator cmp)
3945
{
46+
if ( (end2 - begin2) > (end1 - begin1) )
47+
{
48+
// why in the world would i do this?
49+
// hmmmmmmm.......... !
50+
std::swap(begin1, begin2);
51+
std::swap(end1, end2);
52+
}
4053
while (begin1 != end1 && begin2 != end2)
4154
{
4255
if (cmp( *begin1, *begin2 ) )

0 commit comments

Comments
 (0)