[Freeciv-Dev] (PR#12577) ftwl: faster image_copy_full
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12577 >
image_copy_full is unnecessarily slow because it uses many unnecessary
memcpy's. This patch (untested) fixes that. I suspect it will be quite
measurably faster.
Note that there's no check for overflow. There was no check for
overflow in the old code either. Nor does the function note that the
caller needs to check for overflow. So this function is broken.
-jason
Index: utility/ftwl/be_common_24.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/ftwl/be_common_24.c,v
retrieving revision 1.6
diff -u -r1.6 be_common_24.c
--- utility/ftwl/be_common_24.c 9 Oct 2004 11:59:38 -0000 1.6
+++ utility/ftwl/be_common_24.c 21 Mar 2005 21:38:13 -0000
@@ -570,15 +570,14 @@
int x, y;
for (y = 0; y < region->height; y++) {
- for (x = 0; x < region->width; x++) {
- unsigned char *psrc = IMAGE_GET_ADDRESS(src, x + region->x,
- y + region->y);
- unsigned char *pdest = IMAGE_GET_ADDRESS(dest, x, y);
-
- IMAGE_CHECK(src, x + region->x, y + region->y);
- IMAGE_CHECK(dest, x, y);
- memcpy(pdest, psrc, 4);
- }
+ unsigned char *psrc = IMAGE_GET_ADDRESS(src, region->x,
+ y + region->y);
+ unsigned char *pdest = IMAGE_GET_ADDRESS(dest, 0, y);
+
+ IMAGE_CHECK(src, x + region->x, y + region->y);
+ IMAGE_CHECK(dest, x, y);
+
+ memcpy(pdest, psrc, 4 * region->width);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12577) ftwl: faster image_copy_full,
Jason Short <=
|
|