diff --git a/src/mat.cpp b/src/mat.cpp index 13754e814..35ed2dc11 100644 --- a/src/mat.cpp +++ b/src/mat.cpp @@ -348,10 +348,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left, { outptr[x] = v; } - for (; x < (left + src.w); x++) - { - outptr[x] = ptr[x - left]; - } + memcpy(outptr + left, ptr, src.w * sizeof(float)); + x += src.w; for (; x < w; x++) { outptr[x] = v; @@ -381,10 +379,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left, { outptr[x] = ptr[0]; } - for (; x < (left + src.w); x++) - { - outptr[x] = ptr[x - left]; - } + memcpy(outptr + left, ptr, src.w * sizeof(float)); + x += src.w; for (; x < w; x++) { outptr[x] = ptr[src.w - 1]; @@ -399,10 +395,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left, { outptr[x] = ptr[0]; } - for (; x < (left + src.w); x++) - { - outptr[x] = ptr[x - left]; - } + memcpy(outptr + left, ptr, src.w * sizeof(float)); + x += src.w; for (; x < w; x++) { outptr[x] = ptr[src.w - 1]; @@ -419,10 +413,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left, { outptr[x] = ptr[0]; } - for (; x < (left + src.w); x++) - { - outptr[x] = ptr[x - left]; - } + memcpy(outptr + left, ptr, src.w * sizeof(float)); + x += src.w; for (; x < w; x++) { outptr[x] = ptr[src.w - 1]; @@ -481,10 +473,7 @@ static void copy_cut_border_image(const Mat& src, Mat& dst, int top, int left) for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) - { - outptr[x] = ptr[x]; - } + memcpy(outptr, ptr, w*sizeof(float)); outptr += w; ptr += src.w; }