Skip to content

Commit 7763a86

Browse files
committed
restored memset optimization
when dropping optimizations in the last commit, I forgot to keep the simplest case where a single memset can be called
1 parent fa4fd48 commit 7763a86

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

modules/imgproc/src/drawing.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,18 +1076,23 @@ static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, i
10761076
uchar* hline_min_ptr = (uchar*)(ptr) + (xl)*(pix_size);
10771077
uchar* hline_end_ptr = (uchar*)(ptr) + (xr+1)*(pix_size);
10781078
uchar* hline_ptr = hline_min_ptr;
1079-
if (hline_min_ptr < hline_end_ptr)
1079+
if (pix_size == 1)
1080+
memset(hline_min_ptr, *color, hline_end_ptr-hline_min_ptr);
1081+
else//if (pix_size != 1)
10801082
{
1081-
memcpy(hline_ptr, color, pix_size);
1082-
hline_ptr += pix_size;
1083-
}//end if (hline_min_ptr < hline_end_ptr)
1084-
size_t sizeToCopy = pix_size;
1085-
while(hline_ptr < hline_end_ptr)
1086-
{
1087-
memcpy(hline_ptr, hline_min_ptr, sizeToCopy);
1088-
hline_ptr += sizeToCopy;
1089-
sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr));
1090-
}//end while(hline_ptr < hline_end_ptr)
1083+
if (hline_min_ptr < hline_end_ptr)
1084+
{
1085+
memcpy(hline_ptr, color, pix_size);
1086+
hline_ptr += pix_size;
1087+
}//end if (hline_min_ptr < hline_end_ptr)
1088+
size_t sizeToCopy = pix_size;
1089+
while(hline_ptr < hline_end_ptr)
1090+
{
1091+
memcpy(hline_ptr, hline_min_ptr, sizeToCopy);
1092+
hline_ptr += sizeToCopy;
1093+
sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr));
1094+
}//end while(hline_ptr < hline_end_ptr)
1095+
}//end if (pix_size != 1)
10911096
}
10921097
//end ICV_HLINE_X()
10931098

0 commit comments

Comments
 (0)