Skip to content

Commit

Permalink
branch prediction kinda
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfrey committed Oct 16, 2009
1 parent 756dcd6 commit e734e20
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/set_intersection/intersect.hpp
Expand Up @@ -13,7 +13,13 @@ void linear_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
OutputIterator out)
{

if ( (end2 - begin2) > (end1 - begin1) )
{
// why in the world would i do this?
// hmmmmmmm.......... !
std::swap(begin1, begin2);
std::swap(end1, end2);
}
while (begin1 != end1 && begin2 != end2)
{
if (*begin1 < *begin2)
Expand All @@ -37,6 +43,13 @@ void linear_intersect(InputIterator1 begin1, InputIterator1 end1,
InputIterator2 begin2, InputIterator2 end2,
OutputIterator out, Comparator cmp)
{
if ( (end2 - begin2) > (end1 - begin1) )
{
// why in the world would i do this?
// hmmmmmmm.......... !
std::swap(begin1, begin2);
std::swap(end1, end2);
}
while (begin1 != end1 && begin2 != end2)
{
if (cmp( *begin1, *begin2 ) )
Expand Down

0 comments on commit e734e20

Please sign in to comment.