restored memset optimization

when dropping optimizations in the last commit, I forgot to keep the
simplest case where a single memset can be called
pull/8182/head
chacha21 8 years ago
parent fa4fd48072
commit 7763a86634
  1. 5
      modules/imgproc/src/drawing.cpp

@ -1076,6 +1076,10 @@ static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, i
uchar* hline_min_ptr = (uchar*)(ptr) + (xl)*(pix_size); uchar* hline_min_ptr = (uchar*)(ptr) + (xl)*(pix_size);
uchar* hline_end_ptr = (uchar*)(ptr) + (xr+1)*(pix_size); uchar* hline_end_ptr = (uchar*)(ptr) + (xr+1)*(pix_size);
uchar* hline_ptr = hline_min_ptr; uchar* hline_ptr = hline_min_ptr;
if (pix_size == 1)
memset(hline_min_ptr, *color, hline_end_ptr-hline_min_ptr);
else//if (pix_size != 1)
{
if (hline_min_ptr < hline_end_ptr) if (hline_min_ptr < hline_end_ptr)
{ {
memcpy(hline_ptr, color, pix_size); memcpy(hline_ptr, color, pix_size);
@ -1088,6 +1092,7 @@ static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, i
hline_ptr += sizeToCopy; hline_ptr += sizeToCopy;
sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr)); sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr));
}//end while(hline_ptr < hline_end_ptr) }//end while(hline_ptr < hline_end_ptr)
}//end if (pix_size != 1)
} }
//end ICV_HLINE_X() //end ICV_HLINE_X()

Loading…
Cancel
Save