mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Optimize std/bzip2 flush_repeat_count checks
name old speed new speed delta wuffs_bzip2_decode_10k/clang11 60.5MB/s ± 0% 65.2MB/s ± 0% +7.85% (p=0.008 n=5+5) wuffs_bzip2_decode_100k/clang11 45.7MB/s ± 1% 52.4MB/s ± 0% +14.68% (p=0.008 n=5+5) wuffs_bzip2_decode_10k/gcc10 58.5MB/s ± 0% 60.6MB/s ± 0% +3.67% (p=0.008 n=5+5) wuffs_bzip2_decode_100k/gcc10 46.3MB/s ± 0% 49.2MB/s ± 0% +6.31% (p=0.008 n=5+5)
This commit is contained in:
1 parent
66f194f7e0
commit
bed155bd6f
3 files changed
+49
-57
No files matched your search
@@ -33,7 +33,18 @@ pri func decoder.flush_fast!(dst: base.io_writer) {
|
||||
curr = (entry & 0xFF) as base.u8
|
||||
flush_pointer = entry >> 12
|
||||
|
||||
if flush_repeat_count >= 4 {
|
||||
if flush_repeat_count < 4 {
|
||||
if curr == flush_prev {
|
||||
flush_repeat_count += 1
|
||||
} else {
|
||||
flush_repeat_count = 1
|
||||
}
|
||||
block_checksum_have =
|
||||
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
|
||||
(block_checksum_have ~mod<< 8)
|
||||
args.dst.write_u8_fast!(a: curr)
|
||||
|
||||
} else {
|
||||
flush_repeat_count = curr as base.u32
|
||||
while flush_repeat_count > 0,
|
||||
inv block_size > 0,
|
||||
@@ -47,18 +58,6 @@ pri func decoder.flush_fast!(dst: base.io_writer) {
|
||||
flush_repeat_count -= 1
|
||||
} endwhile
|
||||
flush_repeat_count = 0
|
||||
} else if curr <> flush_prev {
|
||||
flush_repeat_count = 1
|
||||
block_checksum_have =
|
||||
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
|
||||
(block_checksum_have ~mod<< 8)
|
||||
args.dst.write_u8_fast!(a: curr)
|
||||
} else {
|
||||
flush_repeat_count += 1
|
||||
block_checksum_have =
|
||||
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
|
||||
(block_checksum_have ~mod<< 8)
|
||||
args.dst.write_u8_fast!(a: curr)
|
||||
}
|
||||
|
||||
flush_prev = curr
|
||||
|
||||
@@ -33,7 +33,18 @@ pri func decoder.flush_slow?(dst: base.io_writer) {
|
||||
curr = (entry & 0xFF) as base.u8
|
||||
flush_pointer = entry >> 12
|
||||
|
||||
if flush_repeat_count >= 4 {
|
||||
if flush_repeat_count < 4 {
|
||||
if curr == flush_prev {
|
||||
flush_repeat_count += 1
|
||||
} else {
|
||||
flush_repeat_count = 1
|
||||
}
|
||||
block_checksum_have =
|
||||
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
|
||||
(block_checksum_have ~mod<< 8)
|
||||
args.dst.write_u8?(a: curr)
|
||||
|
||||
} else {
|
||||
flush_repeat_count = curr as base.u32
|
||||
while flush_repeat_count > 0,
|
||||
inv block_size > 0,
|
||||
@@ -45,18 +56,6 @@ pri func decoder.flush_slow?(dst: base.io_writer) {
|
||||
flush_repeat_count -= 1
|
||||
} endwhile
|
||||
flush_repeat_count = 0
|
||||
} else if curr <> flush_prev {
|
||||
flush_repeat_count = 1
|
||||
block_checksum_have =
|
||||
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
|
||||
(block_checksum_have ~mod<< 8)
|
||||
args.dst.write_u8?(a: curr)
|
||||
} else {
|
||||
flush_repeat_count += 1
|
||||
block_checksum_have =
|
||||
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
|
||||
(block_checksum_have ~mod<< 8)
|
||||
args.dst.write_u8?(a: curr)
|
||||
}
|
||||
|
||||
flush_prev = curr
|
||||
|
||||
Reference in new issue
Block a user