From abeff31736112d833a877456af88e045398d1e46 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 12 Jan 2019 09:15:30 +1100 Subject: [PATCH] Take an if check out of incrementing lzw's width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit name old speed new speed delta wuffs_gif_decode_1k_bw/clang 245MB/s ± 1% 246MB/s ± 1% ~ (p=0.132 n=48+48) wuffs_gif_decode_1k_color/clang 140MB/s ± 1% 145MB/s ± 1% +3.75% (p=0.000 n=47+47) wuffs_gif_decode_10k_bgra/clang 684MB/s ± 1% 741MB/s ± 1% +8.37% (p=0.000 n=50+47) wuffs_gif_decode_10k_indexed/clang 183MB/s ± 1% 200MB/s ± 1% +9.38% (p=0.000 n=48+44) wuffs_gif_decode_100k_artificial/clang 530MB/s ± 1% 562MB/s ± 0% +6.06% (p=0.000 n=47+48) wuffs_gif_decode_100k_realistic/clang 212MB/s ± 0% 231MB/s ± 0% +9.10% (p=0.000 n=44+48) wuffs_gif_decode_1000k/clang 216MB/s ± 0% 237MB/s ± 1% +9.69% (p=0.000 n=46+48) wuffs_gif_decode_anim_screencap/clang 1.09GB/s ± 0% 1.12GB/s ± 0% +2.57% (p=0.000 n=46+47) wuffs_gif_decode_1k_bw/gcc 265MB/s ± 1% 264MB/s ± 1% -0.29% (p=0.000 n=48+49) wuffs_gif_decode_1k_color/gcc 147MB/s ± 1% 146MB/s ± 0% -0.46% (p=0.000 n=46+47) wuffs_gif_decode_10k_bgra/gcc 603MB/s ± 1% 625MB/s ± 1% +3.62% (p=0.000 n=46+47) wuffs_gif_decode_10k_indexed/gcc 187MB/s ± 1% 195MB/s ± 1% +4.20% (p=0.000 n=48+47) wuffs_gif_decode_100k_artificial/gcc 517MB/s ± 1% 517MB/s ± 1% -0.17% (p=0.001 n=44+48) wuffs_gif_decode_100k_realistic/gcc 213MB/s ± 1% 212MB/s ± 1% -0.69% (p=0.000 n=45+48) wuffs_gif_decode_1000k/gcc 217MB/s ± 1% 216MB/s ± 1% -0.22% (p=0.000 n=46+48) wuffs_gif_decode_anim_screencap/gcc 1.08GB/s ± 1% 1.07GB/s ± 1% -1.00% (p=0.000 n=45+48) wuffs_lzw_decode_20k/clang 251MB/s ± 0% 274MB/s ± 1% +8.80% (p=0.000 n=48+48) wuffs_lzw_decode_100k/clang 430MB/s ± 0% 479MB/s ± 0% +11.29% (p=0.000 n=46+44) wuffs_lzw_decode_20k/gcc 268MB/s ± 1% 273MB/s ± 0% +1.75% (p=0.000 n=47+45) wuffs_lzw_decode_100k/gcc 480MB/s ± 1% 488MB/s ± 1% +1.59% (p=0.000 n=46+47) --- release/c/wuffs-unsupported-snapshot.c | 8 ++++---- std/lzw/decode_lzw.wuffs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index c8a9d4eb..17e674cb 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -7274,8 +7274,8 @@ wuffs_lzw__decoder__read_from(wuffs_lzw__decoder* self, self->private_impl.f_suffixes[v_save_code][0] = ((uint8_t)(v_code)); } v_save_code += 1; - if ((v_save_code == (((uint32_t)(1)) << v_width)) && (v_width < 12)) { - v_width += 1; + if (v_width < 12) { + v_width += (1 & (v_save_code >> v_width)); } v_prev_code = v_code; } @@ -7333,8 +7333,8 @@ wuffs_lzw__decoder__read_from(wuffs_lzw__decoder* self, ((uint8_t)(v_first_byte)); } v_save_code += 1; - if ((v_save_code == (((uint32_t)(1)) << v_width)) && (v_width < 12)) { - v_width += 1; + if (v_width < 12) { + v_width += (1 & (v_save_code >> v_width)); } v_prev_code = v_code; } diff --git a/std/lzw/decode_lzw.wuffs b/std/lzw/decode_lzw.wuffs index b46fd9b6..76128c88 100644 --- a/std/lzw/decode_lzw.wuffs +++ b/std/lzw/decode_lzw.wuffs @@ -195,8 +195,8 @@ pri func decoder.read_from!(src base.io_reader) { } save_code += 1 - if (save_code == ((1 as base.u32) << width)) and (width < 12) { - width += 1 + if width < 12 { + width += 1 & (save_code >> width) } prev_code = code } @@ -268,8 +268,8 @@ pri func decoder.read_from!(src base.io_reader) { } save_code += 1 - if (save_code == ((1 as base.u32) << width)) and (width < 12) { - width += 1 + if width < 12 { + width += 1 & (save_code >> width) } prev_code = code }