Optimize some std/gif if blocks

name                             old speed     new speed     delta

wuffs_lzw_decode_20k/clang       123MB/s ± 1%  124MB/s ± 0%   +0.91%  (p=0.000 n=46+9)
wuffs_lzw_decode_100k/clang      156MB/s ± 1%  164MB/s ± 1%   +5.07%  (p=0.000 n=46+10)

wuffs_lzw_decode_20k/gcc         167MB/s ± 2%  167MB/s ± 0%     ~     (p=0.933 n=46+8)
wuffs_lzw_decode_100k/gcc        243MB/s ± 3%  247MB/s ± 0%   +1.56%  (p=0.000 n=47+9)

wuffs_gif_decode_1k_bw/clang     263MB/s ± 1%  266MB/s ± 1%   +1.02%  (p=0.000 n=46+10)
wuffs_gif_decode_1k_color/clang  147MB/s ± 1%  122MB/s ± 0%  -16.63%  (p=0.000 n=46+10)
wuffs_gif_decode_10k/clang       134MB/s ± 2%  115MB/s ± 1%  -14.02%  (p=0.000 n=49+10)
wuffs_gif_decode_100k/clang      115MB/s ± 1%  113MB/s ± 0%   -1.73%  (p=0.000 n=44+9)
wuffs_gif_decode_1000k/clang     117MB/s ± 1%  115MB/s ± 1%   -2.10%  (p=0.000 n=46+9)

wuffs_gif_decode_1k_bw/gcc       291MB/s ± 1%  298MB/s ± 1%   +2.46%  (p=0.000 n=44+9)
wuffs_gif_decode_1k_color/gcc    138MB/s ± 1%  163MB/s ± 1%  +18.50%  (p=0.000 n=45+10)
wuffs_gif_decode_10k/gcc         134MB/s ± 2%  152MB/s ± 0%  +13.37%  (p=0.000 n=47+9)
wuffs_gif_decode_100k/gcc        121MB/s ± 1%  134MB/s ± 0%  +11.18%  (p=0.000 n=46+8)
wuffs_gif_decode_1000k/gcc       124MB/s ± 2%  138MB/s ± 1%  +11.07%  (p=0.000 n=47+9)
This commit is contained in:
Nigel Tao committed 2018-06-30 08:33:23 +10:00
1 parent 9f76cb71fd
commit 91bf555431
2 files changed
+22 -20

No files matched your search

+10 -9
View File
@@ -72,13 +72,17 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
if save_code <= 4095 {
this.suffixes[save_code] = code as base.u8
this.prefixes[save_code] = prev_code as base.u16
save_code += 1
if (save_code == ((1 as base.u32) << width)) and (width < 12) {
width += 1
}
}
prev_code = code
} else if code == clear_code {
save_code = end_code
prev_code = 0
width = literal_width + 1
continue
} else if code == end_code {
return
@@ -126,18 +130,15 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
if save_code <= 4095 {
this.suffixes[save_code] = c as base.u8
this.prefixes[save_code] = prev_code as base.u16
save_code += 1
if (save_code == ((1 as base.u32) << width)) and (width < 12) {
width += 1
}
}
prev_code = code
} else {
return error "bad code"
}
if save_code <= 4095 {
save_code += 1
if (save_code == ((1 as base.u32) << width)) and (width < 12) {
width += 1
}
}
prev_code = code
}
}