From 0dfbe463185907b6fbe3563ef611adc19993a4cf Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 5 Dec 2014 03:29:33 +0000 Subject: [PATCH] Rewrite scale_line to use std::fill Eliminate inline byte-by-byte store. --- common/2d/bitblt.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/common/2d/bitblt.cpp b/common/2d/bitblt.cpp index ac0c2ac49..a14169bc3 100644 --- a/common/2d/bitblt.cpp +++ b/common/2d/bitblt.cpp @@ -37,6 +37,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #endif #include "compiler-array.h" +#include "compiler-exchange.h" static int gr_bitblt_dest_step_shift = 0; static ubyte *gr_bitblt_fade_table=NULL; @@ -447,23 +448,19 @@ static void gr_bm_ubitblt0x_rle(unsigned w, unsigned h, int dx, int dy, int sx, // rescalling bitmaps, 10/14/99 Jan Bobrowski jb@wizard.ae.krakow.pl -static void scale_line(const uint8_t *in, uint8_t *out, unsigned ilen, unsigned olen) +static void scale_line(const uint8_t *in, uint8_t *out, const uint_fast32_t ilen, const uint_fast32_t olen) { - int a = olen/ilen, b = olen%ilen; - int c = 0, i; - unsigned char *end = out + olen; - while(out= ilen) { c -= ilen; - goto inside; + ++i; } - while(--i>=0) { -inside: - *out++ = *in; - } - in++; + auto e = out + i + 1; + std::fill(exchange(out, e), e, *in++); } }