Run gofmt

This commit is contained in:
Nigel Tao committed 2022-08-21 21:41:06 +10:00
1 parent 315b2e5262
commit be1f605108
9 files changed
+378 -372

No files matched your search

+14 -14
View File
@@ -35,20 +35,20 @@
// To quantify "much faster", on this one C file, this program was 80 times // To quantify "much faster", on this one C file, this program was 80 times
// faster than `clang-format`, even without a column limit: // faster than `clang-format`, even without a column limit:
// //
// $ wc release/c/wuffs-v0.2.c // $ wc release/c/wuffs-v0.2.c
// 11858 35980 431885 release/c/wuffs-v0.2.c // 11858 35980 431885 release/c/wuffs-v0.2.c
// $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null // $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null
// real 0m0.008s // real 0m0.008s
// user 0m0.005s // user 0m0.005s
// sys 0m0.005s // sys 0m0.005s
// $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null // $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null
// real 0m0.668s // real 0m0.668s
// user 0m0.618s // user 0m0.618s
// sys 0m0.032s // sys 0m0.032s
// $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null // $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null
// real 0m0.641s // real 0m0.641s
// user 0m0.585s // user 0m0.585s
// sys 0m0.037s // sys 0m0.037s
// //
// More commentary is at: // More commentary is at:
// https://godoc.org/github.com/google/wuffs/lib/dumbindent // https://godoc.org/github.com/google/wuffs/lib/dumbindent
+137 -137
View File
@@ -33,7 +33,7 @@ https://github.com/google/wuffs/blob/main/doc/spec/rac-spec.md
Usage: Usage:
ractool [flags] [input_filename] ractool [flags] [input_filename]
If no input_filename is given, stdin is used. Either way, output is written to If no input_filename is given, stdin is used. Either way, output is written to
stdout. stdout.
@@ -63,10 +63,10 @@ or temporary disk space.
Examples: Examples:
ractool -decode foo.rac | sha256sum ractool -decode foo.rac | sha256sum
ractool -decode -drange=400..500 foo.rac ractool -decode -drange=400..500 foo.rac
ractool -encode foo.dat > foo.rac ractool -encode foo.dat > foo.rac
ractool -encode -codec=zlib -dchunksize=256k foo.dat > foo.rac ractool -encode -codec=zlib -dchunksize=256k foo.dat > foo.rac
The "400..500" flag value means the 100 bytes ranging from a DSpace offset The "400..500" flag value means the 100 bytes ranging from a DSpace offset
(offset in terms of decompressed bytes, not compressed bytes) of 400 (offset in terms of decompressed bytes, not compressed bytes) of 400
@@ -79,42 +79,42 @@ Similarly, "1m" and "1M" both mean 1 mebibyte (1048576 bytes).
General Flags: General Flags:
-decode -decode
whether to decode the input whether to decode the input
-encode -encode
whether to encode the input whether to encode the input
-quiet -quiet
whether to suppress messages whether to suppress messages
Decode-Related Flags: Decode-Related Flags:
-drange -drange
the "i..j" range to decompress, "..8" means the first 8 bytes the "i..j" range to decompress, "..8" means the first 8 bytes
-singlethreaded -singlethreaded
whether to decode on a single execution thread whether to decode on a single execution thread
Encode-Related Flags: Encode-Related Flags:
-cchunksize -cchunksize
the chunk size (in CSpace) the chunk size (in CSpace)
-codec -codec
the compression codec (default "zstd") the compression codec (default "zstd")
-cpagesize -cpagesize
the page size (in CSpace) the page size (in CSpace)
-dchunksize -dchunksize
the chunk size (in DSpace) the chunk size (in DSpace)
-indexlocation -indexlocation
the index location, "start" or "end" (default "start") the index location, "start" or "end" (default "start")
-resources -resources
comma-separated list of resource files, such as shared dictionaries comma-separated list of resource files, such as shared dictionaries
-tmpdir -tmpdir
directory (e.g. $TMPDIR) for intermediate work; empty means in-memory directory (e.g. $TMPDIR) for intermediate work; empty means in-memory
Codecs: Codecs:
lz4 lz4
zlib zlib
zstd zstd
Only zlib is fully supported. The others will work for the flags' default Only zlib is fully supported. The others will work for the flags' default
values, but they (1) don't support -cchunksize, only -dchunksize, and (2) don't values, but they (1) don't support -cchunksize, only -dchunksize, and (2) don't
@@ -125,123 +125,123 @@ Installation:
Like any other implemented-in-Go program, to install the ractool program: Like any other implemented-in-Go program, to install the ractool program:
go install github.com/google/wuffs/cmd/ractool go install github.com/google/wuffs/cmd/ractool
Extended Example: Extended Example:
-------- --------
$ # Fetch and unzip the enwik8 test file, a sample of Wikipedia. $ # Fetch and unzip the enwik8 test file, a sample of Wikipedia.
$ wget http://mattmahoney.net/dc/enwik8.zip $ wget http://mattmahoney.net/dc/enwik8.zip
$ unzip enwik8.zip $ unzip enwik8.zip
$ # Also zstd-encode it, as a reference point. Using compression level 15, $ # Also zstd-encode it, as a reference point. Using compression level 15,
$ # instead of the default of 3, matches what ractool uses. $ # instead of the default of 3, matches what ractool uses.
$ zstd -15 enwik8 $ zstd -15 enwik8
$ # Create a shared dictionary. Using zstd-the-program produces a $ # Create a shared dictionary. Using zstd-the-program produces a
$ # dictionary that is especially useful for zstd-the-format, but it can $ # dictionary that is especially useful for zstd-the-format, but it can
$ # also be used by other formats as a 'raw' prefix dictionary. $ # also be used by other formats as a 'raw' prefix dictionary.
$ zstd -15 --train -B64K --maxdict=32K -o dict.dat enwik8 $ zstd -15 --train -B64K --maxdict=32K -o dict.dat enwik8
$ # RAC-encode it with various codecs, with and without that dictionary. $ # RAC-encode it with various codecs, with and without that dictionary.
$ ractool -encode -codec=zlib -resources=dict.dat enwik8 > zlib.withdict.rac $ ractool -encode -codec=zlib -resources=dict.dat enwik8 > zlib.withdict.rac
$ ractool -encode -codec=zlib enwik8 > zlib.sansdict.rac $ ractool -encode -codec=zlib enwik8 > zlib.sansdict.rac
$ ractool -encode -codec=zstd -resources=dict.dat enwik8 > zstd.withdict.rac $ ractool -encode -codec=zstd -resources=dict.dat enwik8 > zstd.withdict.rac
$ ractool -encode -codec=zstd enwik8 > zstd.sansdict.rac $ ractool -encode -codec=zstd enwik8 > zstd.sansdict.rac
$ ractool -encode -codec=lz4 enwik8 > lz4.sansdict.rac $ ractool -encode -codec=lz4 enwik8 > lz4.sansdict.rac
$ # The size overhead (comparing RAC+Xxx to Xxx) is about 0.2% (with) or $ # The size overhead (comparing RAC+Xxx to Xxx) is about 0.2% (with) or
$ # 4.8% (sans) for zlib/zip and about 13% (with) or 28% (sans) for zstd, $ # 4.8% (sans) for zlib/zip and about 13% (with) or 28% (sans) for zstd,
$ # depending on whether we used a shared dictionary (with or sans). $ # depending on whether we used a shared dictionary (with or sans).
$ ls -l $ ls -l
total 362080 total 362080
-rw-r----- 1 tao tao 32768 Oct 25 10:10 dict.dat -rw-r----- 1 tao tao 32768 Oct 25 10:10 dict.dat
-rw-r----- 1 tao tao 100000000 Jun 2 2011 enwik8 -rw-r----- 1 tao tao 100000000 Jun 2 2011 enwik8
-rw-r----- 1 tao tao 36445475 Sep 2 2011 enwik8.zip -rw-r----- 1 tao tao 36445475 Sep 2 2011 enwik8.zip
-rw-r----- 1 tao tao 29563109 Jun 2 2011 enwik8.zst -rw-r----- 1 tao tao 29563109 Jun 2 2011 enwik8.zst
-rw-r----- 1 tao tao 58813316 Oct 25 10:17 lz4.sansdict.rac -rw-r----- 1 tao tao 58813316 Oct 25 10:17 lz4.sansdict.rac
-rw-r----- 1 tao tao 38185178 Oct 25 10:16 zlib.sansdict.rac -rw-r----- 1 tao tao 38185178 Oct 25 10:16 zlib.sansdict.rac
-rw-r----- 1 tao tao 36505786 Oct 25 10:16 zlib.withdict.rac -rw-r----- 1 tao tao 36505786 Oct 25 10:16 zlib.withdict.rac
-rw-r----- 1 tao tao 37820491 Oct 25 10:17 zstd.sansdict.rac -rw-r----- 1 tao tao 37820491 Oct 25 10:17 zstd.sansdict.rac
-rw-r----- 1 tao tao 33386395 Oct 25 10:17 zstd.withdict.rac -rw-r----- 1 tao tao 33386395 Oct 25 10:17 zstd.withdict.rac
$ # Check that the decompressed forms all match. $ # Check that the decompressed forms all match.
$ cat enwik8 | sha256sum $ cat enwik8 | sha256sum
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
$ unzip -p enwik8.zip | sha256sum $ unzip -p enwik8.zip | sha256sum
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
$ unzstd --stdout enwik8.zst | sha256sum $ unzstd --stdout enwik8.zst | sha256sum
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
$ for f in *.rac; do ractool -decode $f | sha256sum; done $ for f in *.rac; do ractool -decode $f | sha256sum; done
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 - 2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
$ # Compare how long it takes to produce 8 bytes from the middle of $ # Compare how long it takes to produce 8 bytes from the middle of
$ # the decompressed file, which happens to be the word "Business". $ # the decompressed file, which happens to be the word "Business".
$ time unzip -p enwik8.zip | dd if=/dev/stdin status=none \ $ time unzip -p enwik8.zip | dd if=/dev/stdin status=none \
> iflag=skip_bytes,count_bytes skip=50000000 count=8 > iflag=skip_bytes,count_bytes skip=50000000 count=8
Business Business
real 0m0.379s real 0m0.379s
user 0m0.410s user 0m0.410s
sys 0m0.080s sys 0m0.080s
$ time unzstd --stdout enwik8.zst | dd if=/dev/stdin status=none \ $ time unzstd --stdout enwik8.zst | dd if=/dev/stdin status=none \
> iflag=skip_bytes,count_bytes skip=50000000 count=8 > iflag=skip_bytes,count_bytes skip=50000000 count=8
Business Business
real 0m0.172s real 0m0.172s
user 0m0.141s user 0m0.141s
sys 0m0.103s sys 0m0.103s
$ time ractool -decode -drange=50000000..50000008 zstd.withdict.rac $ time ractool -decode -drange=50000000..50000008 zstd.withdict.rac
Business Business
real 0m0.004s real 0m0.004s
user 0m0.005s user 0m0.005s
sys 0m0.001s sys 0m0.001s
$ # A RAC file's chunks can be decoded in parallel, unlike ZIP, $ # A RAC file's chunks can be decoded in parallel, unlike ZIP,
$ # substantially reducing the real (wall clock) time taken even $ # substantially reducing the real (wall clock) time taken even
$ # though both of these files use DEFLATE (RFC 1951) compression. $ # though both of these files use DEFLATE (RFC 1951) compression.
$ # $ #
$ # Comparing the -singlethreaded time suggests that zlib-the-library's $ # Comparing the -singlethreaded time suggests that zlib-the-library's
$ # DEFLATE implementation is faster than unzip's. $ # DEFLATE implementation is faster than unzip's.
$ time unzip -p enwik8.zip > /dev/null $ time unzip -p enwik8.zip > /dev/null
real 0m0.711s real 0m0.711s
user 0m0.690s user 0m0.690s
sys 0m0.021s sys 0m0.021s
$ time ractool -decode -singlethreaded zlib.withdict.rac > /dev/null $ time ractool -decode -singlethreaded zlib.withdict.rac > /dev/null
real 0m0.519s real 0m0.519s
user 0m0.513s user 0m0.513s
sys 0m0.017s sys 0m0.017s
$ time ractool -decode zlib.withdict.rac > /dev/null $ time ractool -decode zlib.withdict.rac > /dev/null
real 0m0.052s real 0m0.052s
user 0m0.678s user 0m0.678s
sys 0m0.036s sys 0m0.036s
$ # A similar comparison can be made for Zstandard. $ # A similar comparison can be made for Zstandard.
$ time unzstd --stdout enwik8.zst > /dev/null $ time unzstd --stdout enwik8.zst > /dev/null
real 0m0.203s real 0m0.203s
user 0m0.187s user 0m0.187s
sys 0m0.016s sys 0m0.016s
$ time ractool -decode -singlethreaded zstd.withdict.rac > /dev/null $ time ractool -decode -singlethreaded zstd.withdict.rac > /dev/null
real 0m0.235s real 0m0.235s
user 0m0.206s user 0m0.206s
sys 0m0.033s sys 0m0.033s
$ time ractool -decode zstd.withdict.rac > /dev/null $ time ractool -decode zstd.withdict.rac > /dev/null
real 0m0.037s real 0m0.037s
user 0m0.374s user 0m0.374s
sys 0m0.080s sys 0m0.080s
$ # For reference, LZ4 numbers. $ # For reference, LZ4 numbers.
$ time ractool -decode -singlethreaded lz4.sansdict.rac > /dev/null $ time ractool -decode -singlethreaded lz4.sansdict.rac > /dev/null
real 0m0.072s real 0m0.072s
user 0m0.053s user 0m0.053s
sys 0m0.021s sys 0m0.021s
$ time ractool -decode lz4.sansdict.rac > /dev/null $ time ractool -decode lz4.sansdict.rac > /dev/null
real 0m0.024s real 0m0.024s
user 0m0.097s user 0m0.097s
sys 0m0.034s sys 0m0.034s
-------- --------
*/ */
package main package main
+82 -82
View File
@@ -328,12 +328,12 @@ func (n *Raw) SetPackage(tm *t.Map, pkg t.ID) error {
const MaxExprDepth = 255 const MaxExprDepth = 255
// Expr is an expression, such as "i", "+j" or "k + l[m(n, o)].p": // Expr is an expression, such as "i", "+j" or "k + l[m(n, o)].p":
// - ID0: <0|operator|IDOpenParen|IDOpenBracket|IDDotDot|IDDot> // - ID0: <0|operator|IDOpenParen|IDOpenBracket|IDDotDot|IDDot>
// - ID2: <0|literal|ident> // - ID2: <0|literal|ident>
// - LHS: <nil|Expr> // - LHS: <nil|Expr>
// - MHS: <nil|Expr> // - MHS: <nil|Expr>
// - RHS: <nil|Expr|TypeExpr> // - RHS: <nil|Expr|TypeExpr>
// - List0: <Arg|Expr> function call args, assoc. op args or list members. // - List0: <Arg|Expr> function call args, assoc. op args or list members.
// //
// A zero ID0 means an identifier or literal in ID2, like `foo`, `42` or a // A zero ID0 means an identifier or literal in ID2, like `foo`, `42` or a
// status literal like `"#foo"`. // status literal like `"#foo"`.
@@ -468,10 +468,10 @@ func NewExpr(flags Flags, operator t.ID, ident t.ID, lhs *Node, mhs *Node, rhs *
// Assert is "assert RHS via ID2(args)", "choose etc", "pre etc", "inv etc" or // Assert is "assert RHS via ID2(args)", "choose etc", "pre etc", "inv etc" or
// "post etc": // "post etc":
// - ID0: <IDAssert|IDChoose|IDPre|IDInv|IDPost> // - ID0: <IDAssert|IDChoose|IDPre|IDInv|IDPost>
// - ID2: <"-string literal> reason // - ID2: <"-string literal> reason
// - RHS: <Expr> // - RHS: <Expr>
// - List0: <Arg> reason arguments // - List0: <Arg> reason arguments
type Assert Node type Assert Node
func (n *Assert) AsNode() *Node { return (*Node)(n) } func (n *Assert) AsNode() *Node { return (*Node)(n) }
@@ -513,8 +513,8 @@ func NewAssert(keyword t.ID, condition *Expr, reason t.ID, args []*Node) *Assert
} }
// Arg is "name:value". // Arg is "name:value".
// - ID2: <ident> name // - ID2: <ident> name
// - RHS: <Expr> value // - RHS: <Expr> value
type Arg Node type Arg Node
func (n *Arg) AsNode() *Node { return (*Node)(n) } func (n *Arg) AsNode() *Node { return (*Node)(n) }
@@ -530,9 +530,9 @@ func NewArg(name t.ID, value *Expr) *Arg {
} }
// Assign is "LHS = RHS" or "LHS op= RHS" or "RHS": // Assign is "LHS = RHS" or "LHS op= RHS" or "RHS":
// - ID0: operator // - ID0: operator
// - LHS: <nil|Expr> // - LHS: <nil|Expr>
// - RHS: <Expr> // - RHS: <Expr>
type Assign Node type Assign Node
func (n *Assign) AsNode() *Node { return (*Node)(n) } func (n *Assign) AsNode() *Node { return (*Node)(n) }
@@ -550,8 +550,8 @@ func NewAssign(operator t.ID, lhs *Expr, rhs *Expr) *Assign {
} }
// Var is "var ID2 LHS": // Var is "var ID2 LHS":
// - ID2: name // - ID2: name
// - LHS: <TypeExpr> // - LHS: <TypeExpr>
type Var Node type Var Node
func (n *Var) AsNode() *Node { return (*Node)(n) } func (n *Var) AsNode() *Node { return (*Node)(n) }
@@ -569,9 +569,9 @@ func NewVar(name t.ID, xType *TypeExpr) *Var {
} }
// Field is a "name : type" struct field: // Field is a "name : type" struct field:
// - FlagsPrivateData is the initializer need not explicitly memset to zero. // - FlagsPrivateData is the initializer need not explicitly memset to zero.
// - ID2: name // - ID2: name
// - LHS: <TypeExpr> // - LHS: <TypeExpr>
type Field Node type Field Node
func (n *Field) AsNode() *Node { return (*Node)(n) } func (n *Field) AsNode() *Node { return (*Node)(n) }
@@ -590,11 +590,11 @@ func NewField(flags Flags, name t.ID, xType *TypeExpr) *Field {
// IOManip is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or // IOManip is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or
// "io_limit (io:LHS, limit:MHS) { List2 }": // "io_limit (io:LHS, limit:MHS) { List2 }":
// - ID0: <IDIOBind|IDIOLimit> // - ID0: <IDIOBind|IDIOLimit>
// - LHS: <Expr> // - LHS: <Expr>
// - MHS: <Expr> // - MHS: <Expr>
// - RHS: <Expr> // - RHS: <Expr>
// - List2: <Statement> body // - List2: <Statement> body
type IOManip Node type IOManip Node
func (n *IOManip) AsNode() *Node { return (*Node)(n) } func (n *IOManip) AsNode() *Node { return (*Node)(n) }
@@ -617,16 +617,16 @@ func NewIOManip(keyword t.ID, io *Expr, arg1 *Expr, historyPosition *Expr, body
// Iterate is // Iterate is
// "iterate.ID1 (assigns)(length:ID2, advance:ID0, unroll:LHS), List1 { List2 } else RHS": // "iterate.ID1 (assigns)(length:ID2, advance:ID0, unroll:LHS), List1 { List2 } else RHS":
// - FlagsHasBreak is the iterate has an explicit break // - FlagsHasBreak is the iterate has an explicit break
// - FlagsHasContinue is the iterate has an explicit continue // - FlagsHasContinue is the iterate has an explicit continue
// - ID0: advance // - ID0: advance
// - ID1: <0|label> // - ID1: <0|label>
// - ID2: length // - ID2: length
// - LHS: <Expr> unroll // - LHS: <Expr> unroll
// - RHS: <nil|Iterate> // - RHS: <nil|Iterate>
// - List0: <Assign> assigns // - List0: <Assign> assigns
// - List1: <Assert> asserts // - List1: <Assert> asserts
// - List2: <Statement> body // - List2: <Statement> body
type Iterate Node type Iterate Node
func (n *Iterate) AsNode() *Node { return (*Node)(n) } func (n *Iterate) AsNode() *Node { return (*Node)(n) }
@@ -661,12 +661,12 @@ func NewIterate(label t.ID, assigns []*Node, length t.ID, advance t.ID, unroll t
} }
// While is "while.ID1 MHS, List1 { List2 } endwhile.ID1": // While is "while.ID1 MHS, List1 { List2 } endwhile.ID1":
// - FlagsHasBreak is the while has an explicit break // - FlagsHasBreak is the while has an explicit break
// - FlagsHasContinue is the while has an explicit continue // - FlagsHasContinue is the while has an explicit continue
// - ID1: <0|label> // - ID1: <0|label>
// - MHS: <Expr> // - MHS: <Expr>
// - List1: <Assert> asserts // - List1: <Assert> asserts
// - List2: <Statement> body // - List2: <Statement> body
// //
// TODO: should we be able to unroll while loops too? // TODO: should we be able to unroll while loops too?
type While Node type While Node
@@ -699,10 +699,10 @@ func NewWhile(label t.ID, condition *Expr, asserts []*Node) *While {
} }
// If is "if MHS { List2 } else RHS" or "if MHS { List2 } else { List1 }": // If is "if MHS { List2 } else RHS" or "if MHS { List2 } else { List1 }":
// - MHS: <Expr> // - MHS: <Expr>
// - RHS: <nil|If> // - RHS: <nil|If>
// - List1: <Statement> if-false body // - List1: <Statement> if-false body
// - List2: <Statement> if-true body // - List2: <Statement> if-true body
type If Node type If Node
func (n *If) AsNode() *Node { return (*Node)(n) } func (n *If) AsNode() *Node { return (*Node)(n) }
@@ -722,8 +722,8 @@ func NewIf(condition *Expr, bodyIfTrue []*Node, bodyIfFalse []*Node, elseIf *If)
} }
// Choose is "choose ID2: List0": // Choose is "choose ID2: List0":
// - ID2: name // - ID2: name
// - List0: <Expr> method names. // - List0: <Expr> method names.
type Choose Node type Choose Node
func (n *Choose) AsNode() *Node { return (*Node)(n) } func (n *Choose) AsNode() *Node { return (*Node)(n) }
@@ -739,9 +739,9 @@ func NewChoose(name t.ID, args []*Node) *Choose {
} }
// Ret is "return LHS" or "yield LHS": // Ret is "return LHS" or "yield LHS":
// - FlagsReturnsError LHS is an error status // - FlagsReturnsError LHS is an error status
// - ID0: <IDReturn|IDYield> // - ID0: <IDReturn|IDYield>
// - LHS: <Expr> // - LHS: <Expr>
type Ret Node type Ret Node
func (n *Ret) AsNode() *Node { return (*Node)(n) } func (n *Ret) AsNode() *Node { return (*Node)(n) }
@@ -760,8 +760,8 @@ func NewRet(keyword t.ID, value *Expr) *Ret {
} }
// Jump is "break" or "continue", with an optional label, "break.label": // Jump is "break" or "continue", with an optional label, "break.label":
// - ID0: <IDBreak|IDContinue> // - ID0: <IDBreak|IDContinue>
// - ID1: <0|label> // - ID1: <0|label>
type Jump Node type Jump Node
func (n *Jump) AsNode() *Node { return (*Node)(n) } func (n *Jump) AsNode() *Node { return (*Node)(n) }
@@ -784,12 +784,12 @@ const MaxTypeExprDepth = 63
// TypeExpr is a type expression, such as "base.u32", "base.u32[..= 8]", "foo", // TypeExpr is a type expression, such as "base.u32", "base.u32[..= 8]", "foo",
// "pkg.bar", "ptr T", "array[8] T", "slice T" or "table T": // "pkg.bar", "ptr T", "array[8] T", "slice T" or "table T":
// - ID0: <0|IDArray|IDFunc|IDNptr|IDPtr|IDSlice|IDTable> // - ID0: <0|IDArray|IDFunc|IDNptr|IDPtr|IDSlice|IDTable>
// - ID1: <0|pkg> // - ID1: <0|pkg>
// - ID2: <0|type name> // - ID2: <0|type name>
// - LHS: <nil|Expr> // - LHS: <nil|Expr>
// - MHS: <nil|Expr> // - MHS: <nil|Expr>
// - RHS: <nil|TypeExpr> // - RHS: <nil|TypeExpr>
// //
// An IDNptr or IDPtr ID0 means "nptr RHS" or "ptr RHS". RHS is the inner type. // An IDNptr or IDPtr ID0 means "nptr RHS" or "ptr RHS". RHS is the inner type.
// //
@@ -958,14 +958,14 @@ func NewTypeExpr(decorator t.ID, pkg t.ID, name t.ID, alenRecvMin *Node, max *Ex
const MaxBodyDepth = 255 const MaxBodyDepth = 255
// Func is "func ID2.ID0(LHS)(RHS) { List2 }": // Func is "func ID2.ID0(LHS)(RHS) { List2 }":
// - FlagsPublic is "pub" vs "pri" // - FlagsPublic is "pub" vs "pri"
// - ID0: funcName // - ID0: funcName
// - ID1: <0|receiverPkg> (set by calling SetPackage) // - ID1: <0|receiverPkg> (set by calling SetPackage)
// - ID2: <0|receiverName> // - ID2: <0|receiverName>
// - LHS: <Struct> in-parameters // - LHS: <Struct> in-parameters
// - RHS: <Struct> out-parameters // - RHS: <Struct> out-parameters
// - List1: <Assert> asserts // - List1: <Assert> asserts
// - List2: <Statement> body // - List2: <Statement> body
type Func Node type Func Node
func (n *Func) AsNode() *Node { return (*Node)(n) } func (n *Func) AsNode() *Node { return (*Node)(n) }
@@ -1033,9 +1033,9 @@ func NewFunc(flags Flags, filename string, line uint32, receiverName t.ID, funcN
} }
// Status is "error (RHS) ID2" or "suspension (RHS) ID2": // Status is "error (RHS) ID2" or "suspension (RHS) ID2":
// - FlagsPublic is "pub" vs "pri" // - FlagsPublic is "pub" vs "pri"
// - ID1: <0|pkg> (set by calling SetPackage) // - ID1: <0|pkg> (set by calling SetPackage)
// - ID2: message // - ID2: message
type Status Node type Status Node
func (n *Status) AsNode() *Node { return (*Node)(n) } func (n *Status) AsNode() *Node { return (*Node)(n) }
@@ -1055,11 +1055,11 @@ func NewStatus(flags Flags, filename string, line uint32, message t.ID) *Status
} }
// Const is "const ID2 LHS = RHS": // Const is "const ID2 LHS = RHS":
// - FlagsPublic is "pub" vs "pri" // - FlagsPublic is "pub" vs "pri"
// - ID1: <0|pkg> (set by calling SetPackage) // - ID1: <0|pkg> (set by calling SetPackage)
// - ID2: name // - ID2: name
// - LHS: <TypeExpr> // - LHS: <TypeExpr>
// - RHS: <Expr> // - RHS: <Expr>
type Const Node type Const Node
func (n *Const) AsNode() *Node { return (*Node)(n) } func (n *Const) AsNode() *Node { return (*Node)(n) }
@@ -1087,12 +1087,12 @@ func NewConst(flags Flags, filename string, line uint32, name t.ID, xType *TypeE
const MaxImplements = 63 const MaxImplements = 63
// Struct is "struct ID2? implements List0 (List1)": // Struct is "struct ID2? implements List0 (List1)":
// - FlagsPublic is "pub" vs "pri" // - FlagsPublic is "pub" vs "pri"
// - FlagsClassy is "ID2" vs "ID2?" // - FlagsClassy is "ID2" vs "ID2?"
// - ID1: <0|pkg> (set by calling SetPackage) // - ID1: <0|pkg> (set by calling SetPackage)
// - ID2: name // - ID2: name
// - List0: <TypeExpr> implements // - List0: <TypeExpr> implements
// - List1: <Field> fields // - List1: <Field> fields
// //
// The question mark indicates a classy struct - one that supports methods, // The question mark indicates a classy struct - one that supports methods,
// especially coroutines. // especially coroutines.
@@ -1120,7 +1120,7 @@ func NewStruct(flags Flags, filename string, line uint32, name t.ID, implements
} }
// Use is "use ID2": // Use is "use ID2":
// - ID2: <"-string literal> package path // - ID2: <"-string literal> package path
type Use Node type Use Node
func (n *Use) AsNode() *Node { return (*Node)(n) } func (n *Use) AsNode() *Node { return (*Node)(n) }
@@ -1138,7 +1138,7 @@ func NewUse(filename string, line uint32, path t.ID) *Use {
} }
// File is a file of source code: // File is a file of source code:
// - List0: <Const|Func|Status|Struct|Use> top-level declarations // - List0: <Const|Func|Status|Struct|Use> top-level declarations
type File Node type File Node
func (n *File) AsNode() *Node { return (*Node)(n) } func (n *File) AsNode() *Node { return (*Node)(n) }
+15 -12
View File
@@ -201,16 +201,16 @@ type Token struct {
} }
// nBuiltInIDs is the number of built-in IDs. The packing is: // nBuiltInIDs is the number of built-in IDs. The packing is:
// - 0x00 is invalid. // - 0x00 is invalid.
// - 0x01 ..= 0x0F are squiggly punctuation, such as ";", "." and "?". // - 0x01 ..= 0x0F are squiggly punctuation, such as ";", "." and "?".
// - 0x10 ..= 0x1F are squiggly bookends, such as "(", ")" and "]". // - 0x10 ..= 0x1F are squiggly bookends, such as "(", ")" and "]".
// - 0x20 ..= 0x3F are squiggly assignments, such as "=" and "+=". // - 0x20 ..= 0x3F are squiggly assignments, such as "=" and "+=".
// - 0x40 ..= 0x6F are operators, such as "+", "==" and "not". // - 0x40 ..= 0x6F are operators, such as "+", "==" and "not".
// - 0x70 ..= 0xAF are x-ops (disambiguation forms): unary vs binary "+". // - 0x70 ..= 0xAF are x-ops (disambiguation forms): unary vs binary "+".
// - 0xB0 ..= 0xCF are keywords, such as "if" and "return". // - 0xB0 ..= 0xCF are keywords, such as "if" and "return".
// - 0xD0 ..= 0xDF are type modifiers, such as "ptr" and "slice". // - 0xD0 ..= 0xDF are type modifiers, such as "ptr" and "slice".
// - 0xE0 ..= 0xFF are literals, such as "ok" and "true". // - 0xE0 ..= 0xFF are literals, such as "ok" and "true".
// - 0x100 ..= 0x3FF are identifiers, such as "bool", "u32" and "read_u8". // - 0x100 ..= 0x3FF are identifiers, such as "bool", "u32" and "read_u8".
// //
// Squiggly means a sequence of non-alpha-numeric bytes, such as "+" and "&=". // Squiggly means a sequence of non-alpha-numeric bytes, such as "+" and "&=".
const ( const (
@@ -1299,9 +1299,12 @@ func init() {
// addXForms modifies table so that, if table[x] == y, then table[y] = y. // addXForms modifies table so that, if table[x] == y, then table[y] = y.
// //
// For example, for the unaryForms table, the explicit entries are like: // For example, for the unaryForms table, the explicit entries are like:
// IDPlus: IDXUnaryPlus, //
// IDPlus: IDXUnaryPlus,
//
// and this function implicitly addes entries like: // and this function implicitly addes entries like:
// IDXUnaryPlus: IDXUnaryPlus, //
// IDXUnaryPlus: IDXUnaryPlus,
func addXForms(table *[nBuiltInSymbolicIDs]ID) { func addXForms(table *[nBuiltInSymbolicIDs]ID) {
implicitEntries := [nBuiltInSymbolicIDs]bool{} implicitEntries := [nBuiltInSymbolicIDs]bool{}
for _, y := range table { for _, y := range table {
+41 -41
View File
@@ -27,57 +27,57 @@
// repository was 80 times faster than `clang-format`, even without a column // repository was 80 times faster than `clang-format`, even without a column
// limit: // limit:
// //
// $ wc release/c/wuffs-v0.2.c // $ wc release/c/wuffs-v0.2.c
// 11858 35980 431885 release/c/wuffs-v0.2.c // 11858 35980 431885 release/c/wuffs-v0.2.c
// $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null // $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null
// real 0m0.008s // real 0m0.008s
// user 0m0.005s // user 0m0.005s
// sys 0m0.005s // sys 0m0.005s
// $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null // $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null
// real 0m0.668s // real 0m0.668s
// user 0m0.618s // user 0m0.618s
// sys 0m0.032s // sys 0m0.032s
// $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null // $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null
// real 0m0.641s // real 0m0.641s
// user 0m0.585s // user 0m0.585s
// sys 0m0.037s // sys 0m0.037s
// //
// Apart from some rare and largely uninteresting exceptions, the dumbindent // Apart from some rare and largely uninteresting exceptions, the dumbindent
// algorithm only considers: // algorithm only considers:
// //
// ∙ '{' and '}' curly braces, // ∙ '{' and '}' curly braces,
// ∙ '(' and ')' round parentheses, // ∙ '(' and ')' round parentheses,
// ∙ '\n' line breaks, // ∙ '\n' line breaks,
// ∙ ' ' spaces and '\t' tabs that start or end a line, and // ∙ ' ' spaces and '\t' tabs that start or end a line, and
// ∙ strings, comments and preprocessor directives (in order to ignore any of // ∙ strings, comments and preprocessor directives (in order to ignore any of
// the above special characters within them), // the above special characters within them),
// //
// Everything else is an opaque byte. Consider this input: // Everything else is an opaque byte. Consider this input:
// //
// for (i = 0; i < 3; i++) { // for (i = 0; i < 3; i++) {
// j = 0; // Ignore { in a comment. // j = 0; // Ignore { in a comment.
// if (i < j) { foo(); } // if (i < j) { foo(); }
// u = (v + // u = (v +
// w); // w);
// } // }
// //
// From the algorithm's point of view, this input is equivalent to: // From the algorithm's point of view, this input is equivalent to:
// //
// ....(.................).{ // ....(.................).{
// ................................. // .................................
// ...(.....).{....()..} // ...(.....).{....()..}
// ....(... // ....(...
// .); // .);
// } // }
// //
// The formatted output (using the default of 2 spaces per indent level) is: // The formatted output (using the default of 2 spaces per indent level) is:
// //
// ....(.................).{ // ....(.................).{
// ................................. // .................................
// ...(.....).{....()..} // ...(.....).{....()..}
// ....(... // ....(...
// .); // .);
// } // }
// //
// Dumbindent adjusts lines horizontally (indenting) but not vertically (it // Dumbindent adjusts lines horizontally (indenting) but not vertically (it
// does not break or un-break lines, or collapse consecutive blank lines), // does not break or un-break lines, or collapse consecutive blank lines),
@@ -103,9 +103,9 @@
// //
// Similarly, dumbindent will not correct this mis-indentation: // Similarly, dumbindent will not correct this mis-indentation:
// //
// if (condition) // if (condition)
// goto fail; // goto fail;
// goto fail; // goto fail;
// //
// Instead, when automatically or manually generating the input for dumbindent, // Instead, when automatically or manually generating the input for dumbindent,
// it is recommended to always emit curly braces (again, similar to `gofmt` // it is recommended to always emit curly braces (again, similar to `gofmt`
+14 -14
View File
@@ -130,23 +130,23 @@ func (b *bitstream) take(nBits uint32) int32 {
// 4, 4)" example from RFC 1951 section 3.2.2, the huffman struct is // 4, 4)" example from RFC 1951 section 3.2.2, the huffman struct is
// initialized by calling: // initialized by calling:
// //
// h.construct([]uint32{ // h.construct([]uint32{
// 'A': 3, 'B': 3, 'C': 3, 'D': 3, 'E': 3, 'F': 2, 'G': 4, 'H': 4, // 'A': 3, 'B': 3, 'C': 3, 'D': 3, 'E': 3, 'F': 2, 'G': 4, 'H': 4,
// }) // })
// //
// which results in: // which results in:
// //
// huffman{ // huffman{
// counts: [maxCodeBits + 1]uint32{ // counts: [maxCodeBits + 1]uint32{
// 2: 1, 3: 5, 4: 2, // 2: 1, 3: 5, 4: 2,
// }, // },
// symbols: [maxNumCodes]int32{ // symbols: [maxNumCodes]int32{
// 0: 'F', 1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'G', 7: 'H', // 0: 'F', 1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'G', 7: 'H',
// }, // },
// lookUpTable: [256]uint32{ // lookUpTable: [256]uint32{
// etc, // etc,
// }, // },
// } // }
// //
// Continuing the example from the RFC, decoding "1110" from the bitstream will // Continuing the example from the RFC, decoding "1110" from the bitstream will
// produce the 'G' symbol. // produce the 'G' symbol.
+31 -28
View File
@@ -1057,18 +1057,19 @@ func orOneNegOneNonNeg(neg IntRange, non IntRange) (z IntRange) {
// possible xx in x and yy in y. // possible xx in x and yy in y.
// //
// Algorithm: // Algorithm:
// // If the two intervals overlap, the result is the minimum of the two //
// // intervals' maxima. // // If the two intervals overlap, the result is the minimum of the two
// // // // intervals' maxima.
// // This overlaps code path is just an optimization. // //
// if overlaps(x, y) { // // This overlaps code path is just an optimization.
// return min(xMax, yMax) // if overlaps(x, y) {
// } // return min(xMax, yMax)
// xFlip = bitFillRight(bitFillRight(xMax & ~xMin) & xMax & ~yMax) // }
// xResult = yMax & ((xMax & ~xFlip) | (xFlip >> 1)) // xFlip = bitFillRight(bitFillRight(xMax & ~xMin) & xMax & ~yMax)
// yFlip = bitFillRight(bitFillRight(yMax & ~yMin) & yMax & ~xMax) // xResult = yMax & ((xMax & ~xFlip) | (xFlip >> 1))
// yResult = xMax & ((yMax & ~yFlip) | (yFlip >> 1)) // yFlip = bitFillRight(bitFillRight(yMax & ~yMin) & yMax & ~xMax)
// return max(xResult, yResult) // yResult = xMax & ((yMax & ~yFlip) | (yFlip >> 1))
// return max(xResult, yResult)
// //
// If xMin and yMin are both zero, the overlaps branch is taken. // If xMin and yMin are both zero, the overlaps branch is taken.
// //
@@ -1189,13 +1190,15 @@ func (x IntRange) andMax(y IntRange) *big.Int {
// possible xx in x and yy in y. // possible xx in x and yy in y.
// //
// Algorithm: // Algorithm:
// droppable = bitFillRight((xMax & ~xMin) | (yMax & ~yMin)) //
// available = xMax & yMax & droppable // droppable = bitFillRight((xMax & ~xMin) | (yMax & ~yMin))
// return xMax | yMax | (bitFillRight(available) >> 1) // available = xMax & yMax & droppable
// return xMax | yMax | (bitFillRight(available) >> 1)
// //
// If xMin and yMin are both zero, this simplifies to: // If xMin and yMin are both zero, this simplifies to:
// available = xMax & yMax //
// return xMax | yMax | (bitFillRight(available) >> 1) // available = xMax & yMax
// return xMax | yMax | (bitFillRight(available) >> 1)
func (x IntRange) orMax(y IntRange) *big.Int { func (x IntRange) orMax(y IntRange) *big.Int {
if x[0].Sign() == 0 && y[0].Sign() == 0 { if x[0].Sign() == 0 && y[0].Sign() == 0 {
i := big.NewInt(0) i := big.NewInt(0)
@@ -1257,17 +1260,17 @@ func (x IntRange) orMax(y IntRange) *big.Int {
} }
// bitFillRight modifies i to round up to the next power of 2 minus 1: // bitFillRight modifies i to round up to the next power of 2 minus 1:
// - If i is +0 then bitFillRight(i) sets i to 0. // - If i is +0 then bitFillRight(i) sets i to 0.
// - If i is +1 then bitFillRight(i) sets i to 1. // - If i is +1 then bitFillRight(i) sets i to 1.
// - If i is +2 then bitFillRight(i) sets i to 3. // - If i is +2 then bitFillRight(i) sets i to 3.
// - If i is +3 then bitFillRight(i) sets i to 3. // - If i is +3 then bitFillRight(i) sets i to 3.
// - If i is +4 then bitFillRight(i) sets i to 7. // - If i is +4 then bitFillRight(i) sets i to 7.
// - If i is +5 then bitFillRight(i) sets i to 7. // - If i is +5 then bitFillRight(i) sets i to 7.
// - If i is +6 then bitFillRight(i) sets i to 7. // - If i is +6 then bitFillRight(i) sets i to 7.
// - If i is +7 then bitFillRight(i) sets i to 7. // - If i is +7 then bitFillRight(i) sets i to 7.
// - If i is +8 then bitFillRight(i) sets i to 15. // - If i is +8 then bitFillRight(i) sets i to 15.
// - If i is +9 then bitFillRight(i) sets i to 15. // - If i is +9 then bitFillRight(i) sets i to 15.
// - Etc. // - Etc.
func bitFillRight(i *big.Int) { func bitFillRight(i *big.Int) {
if s := i.Sign(); s < 0 { if s := i.Sign(); s < 0 {
panic("pre-condition failure") panic("pre-condition failure")
+43 -43
View File
@@ -30,23 +30,23 @@
// //
// Example compression numbers on a small English text file (at // Example compression numbers on a small English text file (at
// https://github.com/google/wuffs/blob/main/test/data/romeo.txt): // https://github.com/google/wuffs/blob/main/test/data/romeo.txt):
// - romeo.txt is 942 bytes (100%). // - romeo.txt is 942 bytes (100%).
// - romeo.txt.litonlylzma is 659 bytes (70%). // - romeo.txt.litonlylzma is 659 bytes (70%).
// - romeo.txt.xz is 644 bytes (68%). // - romeo.txt.xz is 644 bytes (68%).
// - romeo.txt.lzma is 598 bytes (63%). // - romeo.txt.lzma is 598 bytes (63%).
// - romeo.txt.bz2 is 568 bytes (60%). // - romeo.txt.bz2 is 568 bytes (60%).
// - romeo.txt.zst is 559 bytes (59%). // - romeo.txt.zst is 559 bytes (59%).
// - romeo.txt.gz is 558 bytes (59%). // - romeo.txt.gz is 558 bytes (59%).
// //
// Example compression numbers on a large archive of source code (at // Example compression numbers on a large archive of source code (at
// https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.1.tar.xz): // https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.1.tar.xz):
// - linux-5.0.1.tar is 863313920 bytes (100%). // - linux-5.0.1.tar is 863313920 bytes (100%).
// - linux-5.0.1.tar.litonlylzma is 449726070 bytes (52%). // - linux-5.0.1.tar.litonlylzma is 449726070 bytes (52%).
// - linux-5.0.1.tar.gz is 164575959 bytes (19%). // - linux-5.0.1.tar.gz is 164575959 bytes (19%).
// - linux-5.0.1.tar.zst is 156959897 bytes (18%). // - linux-5.0.1.tar.zst is 156959897 bytes (18%).
// - linux-5.0.1.tar.bz2 is 125873134 bytes (15%). // - linux-5.0.1.tar.bz2 is 125873134 bytes (15%).
// - linux-5.0.1.tar.xz is 108233572 bytes (13%). // - linux-5.0.1.tar.xz is 108233572 bytes (13%).
// - linux-5.0.1.tar.lzma is 108216601 bytes (13%). // - linux-5.0.1.tar.lzma is 108216601 bytes (13%).
// //
// The various tools (/usr/bin/gzip, /usr/bin/xz, etc) were all ran with their // The various tools (/usr/bin/gzip, /usr/bin/xz, etc) were all ran with their
// default settings, not their "maximum compression" settings. This is why the // default settings, not their "maximum compression" settings. This is why the
@@ -260,39 +260,39 @@ func (p *prob) encodeBit(rEnc *rangeEncoder, bitValue uint32) {
// byteProbs hold probabilities for coding 8 bits (1 byte) of data. It is a 256 // byteProbs hold probabilities for coding 8 bits (1 byte) of data. It is a 256
// element array such that: // element array such that:
// - The 0th element is unused. // - The 0th element is unused.
// - The 1st element holds the probability that the 7th bit (the highest, most // - The 1st element holds the probability that the 7th bit (the highest, most
// significant bit) is 0. // significant bit) is 0.
// - The 2nd element holds the probability that the 6th bit is 0, conditional // - The 2nd element holds the probability that the 6th bit is 0, conditional
// on the high bit being 0. // on the high bit being 0.
// - The 3rd element holds the probability that the 6th bit is 0, conditional // - The 3rd element holds the probability that the 6th bit is 0, conditional
// on the high bit being 1. // on the high bit being 1.
// - The 4th element holds the probability that the 5th bit is 0, conditional // - The 4th element holds the probability that the 5th bit is 0, conditional
// on the high two bits being 00. // on the high two bits being 00.
// - The 5th element holds the probability that the 5th bit is 0, conditional // - The 5th element holds the probability that the 5th bit is 0, conditional
// on the high two bits being 01. // on the high two bits being 01.
// - The 6th element holds the probability that the 5th bit is 0, conditional // - The 6th element holds the probability that the 5th bit is 0, conditional
// on the high two bits being 10. // on the high two bits being 10.
// - The 7th element holds the probability that the 5th bit is 0, conditional // - The 7th element holds the probability that the 5th bit is 0, conditional
// on the high two bits being 11. // on the high two bits being 11.
// - The 8th element holds the probability that the 4th bit is 0, conditional // - The 8th element holds the probability that the 4th bit is 0, conditional
// on the high three bits being 000. // on the high three bits being 000.
// - etc // - etc
// - The 255th element holds the probability that the 0th bit (the lowest, // - The 255th element holds the probability that the 0th bit (the lowest,
// least significant bit) is 0, conditional on the high seven bits being // least significant bit) is 0, conditional on the high seven bits being
// 1111111. // 1111111.
// //
// Put another way, the 256 elements' value of N, as in "it's a probability for // Put another way, the 256 elements' value of N, as in "it's a probability for
// the Nth bit", looks like this (when arranged in 8 rows of 32 elements): // the Nth bit", looks like this (when arranged in 8 rows of 32 elements):
// //
// u7665555444444443333333333333333 // u7665555444444443333333333333333
// 22222222222222222222222222222222 // 22222222222222222222222222222222
// 11111111111111111111111111111111 // 11111111111111111111111111111111
// 11111111111111111111111111111111 // 11111111111111111111111111111111
// 00000000000000000000000000000000 // 00000000000000000000000000000000
// 00000000000000000000000000000000 // 00000000000000000000000000000000
// 00000000000000000000000000000000 // 00000000000000000000000000000000
// 00000000000000000000000000000000 // 00000000000000000000000000000000
// //
// The 'u' means that the 0th element is unused. // The 'u' means that the 0th element is unused.
type byteProbs [0x100]prob type byteProbs [0x100]prob
+1 -1
View File
@@ -365,7 +365,7 @@ type bitVector []uint8
// zig packs a pair of non-negative integers (i, j) into a single unique // zig packs a pair of non-negative integers (i, j) into a single unique
// non-negative integer, in a zig-zagging pattern: // non-negative integer, in a zig-zagging pattern:
// //
// i=0 i=1 i=2 i=3 i=4 etc // . i=0 i=1 i=2 i=3 i=4 etc
// j=0: 0 1 3 6 10 ... // j=0: 0 1 3 6 10 ...
// j=1: 2 4 7 11 16 ... // j=1: 2 4 7 11 16 ...
// j=2: 5 8 12 17 23 ... // j=2: 5 8 12 17 23 ...