mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 08:47:28 +01:00
Add a reader1.unread_u8 method.
Also re-enable a number of std/flate tests and benchmarks. It's not an optimization per se, but as a data point, here are some benchmark numbers between36a93faand this commit.36a93fais "36a93fa Add a TODO about impure functions", which is one commit before "f968950 Read bits up front in decode_huffman_fast", andf968950was the commit that made decode_huffman_fast read more than one byte at a time. name old speed new speed delta puffs_adler32_10k/clang 2.45GB/s ± 0% 2.45GB/s ± 0% ~ (p=0.684 n=10+10) puffs_adler32_100k/clang 2.45GB/s ± 0% 2.46GB/s ± 0% +0.07% (p=0.019 n=10+10) puffs_flate_decode_1k/clang 124MB/s ± 0% 132MB/s ± 0% +6.06% (p=0.000 n=10+10) puffs_flate_decode_10k/clang 145MB/s ± 0% 174MB/s ± 0% +20.19% (p=0.000 n=9+10) puffs_flate_decode_100k/clang 168MB/s ± 0% 208MB/s ± 0% +23.31% (p=0.000 n=10+10) puffs_zlib_decode_10k/clang 136MB/s ± 0% 162MB/s ± 0% +18.94% (p=0.000 n=10+9) puffs_zlib_decode_100k/clang 158MB/s ± 0% 192MB/s ± 0% +21.58% (p=0.000 n=10+9) puffs_adler32_10k/gcc 3.26GB/s ± 0% 3.26GB/s ± 0% ~ (p=0.631 n=10+10) puffs_adler32_100k/gcc 3.27GB/s ± 0% 3.27GB/s ± 0% ~ (p=0.237 n=10+8) puffs_flate_decode_1k/gcc 95.3MB/s ± 0% 105.5MB/s ± 0% +10.67% (p=0.000 n=10+10) puffs_flate_decode_10k/gcc 110MB/s ± 0% 140MB/s ± 0% +27.32% (p=0.000 n=9+9) puffs_flate_decode_100k/gcc 121MB/s ± 0% 150MB/s ± 0% +24.02% (p=0.000 n=8+10) puffs_zlib_decode_10k/gcc 112MB/s ± 0% 120MB/s ± 0% +6.96% (p=0.000 n=10+9) puffs_zlib_decode_100k/gcc 123MB/s ± 0% 134MB/s ± 0% +8.93% (p=0.000 n=9+8)
This commit is contained in:
1 parent
6621526a2c
commit
13731f989f
7 files changed
+38
-16
No files matched your search
@@ -734,7 +734,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
}
|
||||
|
||||
// TODO: delete this hack that only matches "in.src.read_u8?()" etc.
|
||||
if isInSrc(q.tm, n, t.KeyReadU8, 0) ||
|
||||
if isInSrc(q.tm, n, t.KeyReadU8, 0) || isInSrc(q.tm, n, t.KeyUnreadU8, 0) ||
|
||||
isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU32BE, 0) ||
|
||||
isInSrc(q.tm, n, t.KeyReadU32BE, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
|
||||
isInSrc(q.tm, n, t.KeySkip32, 1) || isInSrc(q.tm, n, t.KeySinceMark, 0) ||
|
||||
@@ -1170,7 +1170,8 @@ func (q *checker) bcheckIOMethods(n *a.Expr, depth uint32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Figure out the "receiver" in "receiver.read_u8?()".
|
||||
// Figure out the "receiver" in "receiver.read_xxx?()", for some I/O method
|
||||
// "read_xxx".
|
||||
if n.ID0().Key() != t.KeyOpenParen {
|
||||
return nil
|
||||
}
|
||||
@@ -1179,7 +1180,10 @@ func (q *checker) bcheckIOMethods(n *a.Expr, depth uint32) error {
|
||||
return nil
|
||||
}
|
||||
advance := (*big.Int)(nil)
|
||||
if key := receiver.ID1().Key(); key < t.Key(len(ioMethodAdvances)) {
|
||||
if key := receiver.ID1().Key(); key == t.KeyUnreadU8 {
|
||||
// TODO: call SetProvenNotToSuspend, since unread_u8 can never suspend,
|
||||
// only succeed or fail.
|
||||
} else if key < t.Key(len(ioMethodAdvances)) {
|
||||
advance = ioMethodAdvances[key]
|
||||
}
|
||||
if advance == nil {
|
||||
|
||||
+1
-1
@@ -407,7 +407,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
// require a TypeExpr being able to express function and method types.
|
||||
|
||||
// TODO: delete this hack that only matches "in.src.read_u8?()" etc.
|
||||
if isInSrc(q.tm, n, t.KeyReadU8, 0) ||
|
||||
if isInSrc(q.tm, n, t.KeyReadU8, 0) || isInSrc(q.tm, n, t.KeyUnreadU8, 0) ||
|
||||
isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU32BE, 0) ||
|
||||
isInSrc(q.tm, n, t.KeyReadU32BE, 0) || isInSrc(q.tm, n, t.KeyReadU32LE, 0) ||
|
||||
isInSrc(q.tm, n, t.KeySkip32, 1) || isInSrc(q.tm, n, t.KeySinceMark, 0) ||
|
||||
|
||||
Reference in new issue
Block a user