Skip to content
Permalink
Browse files

branch prediction kinda

  • Loading branch information...
erikfrey committed Oct 16, 2009
1 parent 756dcd6 commit e734e20712404bd403d7e103673d4b253df75247
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/set_intersection/intersect.hpp
@@ -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)
@@ -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 ) )

0 comments on commit e734e20

Please sign in to comment.
You can’t perform that action at this time.