Skip to content

Commit 8ad8b95

Browse files
authored
More minor cleanup (#8)
1 parent 3804e0b commit 8ad8b95

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,20 @@ but retain high decompression speed.
2727
* Fast detection of pre-compressed data
2828
* Powerful commandline utility
2929

30-
This package implements the MinLZ specification v1.0.
30+
This package implements the MinLZ specification v1.0 in Go.
3131

3232
For format specification see the included [SPEC.md](SPEC.md).
3333

3434
# Changelog
3535

3636
* [v1.0.0](https://github.com/minio/minlz/releases/tag/v1.0.0)
37-
* [Initial Release Blog Post](https://gist.github.com/klauspost/a25b66198cdbdf7b5b224f670c894ed5).
37+
* [Initial Release Blog Post](https://blog.min.io/minlz-compression-algorithm/).
3838

3939
# Usage
4040

41+
[![Go Reference](https://pkg.go.dev/badge/minio/minlz.svg)](https://pkg.go.dev/github.com/minio/minlz?tab=subdirectories)
42+
[![Go](https://github.com/minio/minlz/actions/workflows/go.yml/badge.svg)](https://github.com/minio/minlz/actions/workflows/go.yml)
43+
4144
MinLZ can operate on *blocks* up to 8 MB or *streams* with unlimited length.
4245

4346
Blocks are the simplest, but do not provide any output validation.
@@ -808,9 +811,11 @@ If you are interested in porting MinLZ to another language, open a discussion to
808811

809812
If you do a port, feel free to send in a PR for this table:
810813

811-
| Language | Repository Link | License | Features as described in SPEC.md |
812-
|----------|----------------------------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------|
813-
| Go | [github.com/minio/minlz](https://github.com/minio/minlz) | Apache 2.0 | `[x] Block Read [x] Block Write [x] Stream Read [x] Stream Write [x] Index Support [x] Snappy Read Fallback` |
814+
| Language | Repository Link | License | Block Read | Block Write | Stream Read | Stream Write | Index | Snappy Fallback |
815+
|----------|-----------------------------------------------------------------------------------------|------------|------------|-------------|-------------|--------------|-------|-----------------|
816+
| Go | [github.com/minio/minlz](https://github.com/minio/minlz) | Apache 2.0 |||||||
817+
| C | [Experimental GIST](https://gist.github.com/klauspost/5796a5aa116a15eb7341ffa8427bbe7a) | CC0 ||| | | | |
818+
814819

815820
Indicated features must support all parts of each feature as described in the specification.
816821
However, it is up to the implementation to decide the encoding implementation(s).

decode.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"encoding/binary"
1919
"errors"
2020
"fmt"
21-
"strconv"
2221

2322
"github.com/klauspost/compress/s2"
2423
)
@@ -410,7 +409,7 @@ func minLZDecodeGo(dst, src []byte) int {
410409
goto doCopy2
411410
}
412411

413-
if length > len(dst)-d || length > len(src)-s || (strconv.IntSize == 32 && length <= 0) {
412+
if length > len(dst)-d || length > len(src)-s {
414413
if debugErrors {
415414
fmt.Println("corrupt: lit size", length, "dst avail:", len(dst)-d, "src avail:", len(src)-s, "dst pos:", d)
416415
}

encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const (
4646
minCopy2Length = 64
4747

4848
maxCopy3Lits = 1<<copyLitBits - 1
49-
minCopy3Offset = 65536 // 2MiB
49+
minCopy3Offset = 65536
5050
maxCopy3Offset = 2<<20 + 65535 // 2MiB
5151
minCopy3Length = 64
5252
)

encode_l1.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,6 @@ func encodeBlockGo(dst, src []byte) (d int) {
174174
}
175175

176176
// A 4-byte match has been found. We'll later see if more than 4 bytes match.
177-
178-
// Call emitCopy, and then see if another emitCopy could be our next
179-
// move. Repeat until we find no match for the input immediately after
180-
// what was consumed by the last emitCopy call.
181-
//
182-
// If we exit this loop normally then we need to call emitLiteral next,
183-
// though we don't yet know how big the literal will be. We handle that
184-
// by proceeding to the next iteration of the main loop. We also can
185-
// exit this loop via goto if we get close to exhausting the input.
186-
187-
// Invariant: we have a 4-byte match at s, and no need to emit any
188-
// literal bytes prior to s.
189177
base := s
190178
repeat = base - candidate
191179

@@ -429,18 +417,6 @@ func encodeBlockGo64K(dst, src []byte) (d int) {
429417
}
430418

431419
// A 4-byte match has been found. We'll later see if more than 4 bytes match.
432-
433-
// Call emitCopy, and then see if another emitCopy could be our next
434-
// move. Repeat until we find no match for the input immediately after
435-
// what was consumed by the last emitCopy call.
436-
//
437-
// If we exit this loop normally then we need to call emitLiteral next,
438-
// though we don't yet know how big the literal will be. We handle that
439-
// by proceeding to the next iteration of the main loop. We also can
440-
// exit this loop via goto if we get close to exhausting the input.
441-
442-
// Invariant: we have a 4-byte match at s, and no need to emit any
443-
// literal bytes prior to s.
444420
base := s
445421
repeat = base - candidate
446422

0 commit comments

Comments
 (0)