From 19c37bbcb3044bd97298f6acce26443557a0f685 Mon Sep 17 00:00:00 2001 From: Dabb Date: Tue, 20 Feb 2001 16:52:24 +0000 Subject: [PATCH] Some optimizations, use memset instead of for loop with *bl++=0. Uses almost 1% less CPU for me :-) --- source/gl_rsurf.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index 0bfa3ba..06efc1a 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -235,29 +235,19 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride) // set to full bright if no light data if (!cl.worldmodel->lightdata) { - bl = blocklights; - for (i = 0; i < size; i++) { - *bl++ = 255 << 8; - *bl++ = 255 << 8; - *bl++ = 255 << 8; - } + memset (&blocklights[0], 255, size * 3 * sizeof (unsigned int)); goto store; } // clear to no light - bl = blocklights; - for (i = 0; i < size; i++) { - *bl++ = 0; - *bl++ = 0; - *bl++ = 0; - } - bl = blocklights; + + memset (&blocklights[0], 0, size * 3 * sizeof (unsigned int)); // add all the lightmaps if (lightmap) { for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) { scale = d_lightstylevalue[surf->styles[maps]]; surf->cached_light[maps] = scale; // 8.8 fraction - bl = blocklights; + bl=blocklights; for (i = 0; i < size; i++) { *bl++ += *lightmap++ * scale; *bl++ += *lightmap++ * scale;