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

+12 -11
View File
@@ -2170,7 +2170,6 @@ wuffs_base__status wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
v_width = (v_literal_width + 1);
v_bits = 0;
v_n_bits = 0;
label_0_continue:;
while (true) {
while (v_n_bits < v_width) {
{
@@ -2197,12 +2196,16 @@ wuffs_base__status wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
self->private_impl.f_suffixes[v_save_code] = ((uint8_t)(v_code));
self->private_impl.f_prefixes[v_save_code] =
((uint16_t)(v_prev_code));
v_save_code += 1;
if ((v_save_code == (((uint32_t)(1)) << v_width)) && (v_width < 12)) {
v_width += 1;
}
}
v_prev_code = v_code;
} else if (v_code == v_clear_code) {
v_save_code = v_end_code;
v_prev_code = 0;
v_width = (v_literal_width + 1);
goto label_0_continue;
} else if (v_code == v_end_code) {
status = WUFFS_BASE__STATUS_OK;
goto ok;
@@ -2234,29 +2237,27 @@ wuffs_base__status wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
v_n_copied = wuffs_base__io_writer__copy_from_slice(
&ioptr_dst, iobounds1_dst, v_expansion);
if (v_n_copied == ((uint64_t)(v_expansion.len))) {
goto label_1_break;
goto label_0_break;
}
v_s = ((v_s + ((uint32_t)((v_n_copied & 4095)))) & 4095);
status = WUFFS_BASE__SUSPENSION_SHORT_WRITE;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
}
label_1_break:;
label_0_break:;
if (v_save_code <= 4095) {
self->private_impl.f_suffixes[v_save_code] = ((uint8_t)(v_c));
self->private_impl.f_prefixes[v_save_code] =
((uint16_t)(v_prev_code));
v_save_code += 1;
if ((v_save_code == (((uint32_t)(1)) << v_width)) && (v_width < 12)) {
v_width += 1;
}
}
v_prev_code = v_code;
} else {
status = WUFFS_LZW__ERROR_BAD_CODE;
goto exit;
}
if (v_save_code <= 4095) {
v_save_code += 1;
if ((v_save_code == (((uint32_t)(1)) << v_width)) && (v_width < 12)) {
v_width += 1;
}
}
v_prev_code = v_code;
}
goto ok;
+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
}
}