mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 20:42:53 +08:00
restored memset optimization
when dropping optimizations in the last commit, I forgot to keep the simplest case where a single memset can be called
This commit is contained in:
parent
fa4fd48072
commit
7763a86634
@ -1076,18 +1076,23 @@ 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 (hline_min_ptr < hline_end_ptr)
|
if (pix_size == 1)
|
||||||
|
memset(hline_min_ptr, *color, hline_end_ptr-hline_min_ptr);
|
||||||
|
else//if (pix_size != 1)
|
||||||
{
|
{
|
||||||
memcpy(hline_ptr, color, pix_size);
|
if (hline_min_ptr < hline_end_ptr)
|
||||||
hline_ptr += pix_size;
|
{
|
||||||
}//end if (hline_min_ptr < hline_end_ptr)
|
memcpy(hline_ptr, color, pix_size);
|
||||||
size_t sizeToCopy = pix_size;
|
hline_ptr += pix_size;
|
||||||
while(hline_ptr < hline_end_ptr)
|
}//end if (hline_min_ptr < hline_end_ptr)
|
||||||
{
|
size_t sizeToCopy = pix_size;
|
||||||
memcpy(hline_ptr, hline_min_ptr, sizeToCopy);
|
while(hline_ptr < hline_end_ptr)
|
||||||
hline_ptr += sizeToCopy;
|
{
|
||||||
sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr));
|
memcpy(hline_ptr, hline_min_ptr, sizeToCopy);
|
||||||
}//end while(hline_ptr < hline_end_ptr)
|
hline_ptr += sizeToCopy;
|
||||||
|
sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr));
|
||||||
|
}//end while(hline_ptr < hline_end_ptr)
|
||||||
|
}//end if (pix_size != 1)
|
||||||
}
|
}
|
||||||
//end ICV_HLINE_X()
|
//end ICV_HLINE_X()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user