Skip to content

Commit

Permalink
use BestCompression level for gzip writer
Browse files Browse the repository at this point in the history
In the context of vfsgen, it should be a favorable trade-off to spend
more time and effort when performing file compression, if it can lead
to file sizes being reduced further.

The previous choice of compression level (DefaultCompression)
was inherited from this project's go-bindata lineage.

Fixes #85.

GitHub-Pull-Request: #86
  • Loading branch information
silverwind authored Aug 24, 2020
1 parent 92b8a71 commit 0d455de
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func writeCompressedFileInfo(w io.Writer, file *fileInfo, r io.Reader) error {
return err
}
sw := &stringWriter{Writer: w}
gw := gzip.NewWriter(sw)
gw, _ := gzip.NewWriterLevel(sw, gzip.BestCompression)
_, err = io.Copy(gw, r)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion test/test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func Example_compressed() {
// <not compressed>
// /sample-file.txt
// "This file compresses well. Blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah!" <nil>
// "\x1f\x8b\b\x00\x00\x00\x00\x00\x00\xff\n\xc9\xc8,VH\xcb\xccIUH\xce\xcf-(J-.N-V(O\xcd\xc9\xd1Sp\xcaI\x1c\xd4 C\x11\x10\x00\x00\xff\xff\xe7G\x81:\xbd\x00\x00\x00"
// "\x1f\x8b\b\x00\x00\x00\x00\x00\x02\xff\n\xc9\xc8,VH\xcb\xccIUH\xce\xcf-(J-.N-V(O\xcd\xc9\xd1Sp\xcaI\x1c\xd4 C\x11\x10\x00\x00\xff\xff\xe7G\x81:\xbd\x00\x00\x00"
}

func Example_readTwoOpenedCompressedFiles() {
Expand Down
2 changes: 1 addition & 1 deletion test/test_vfsdata_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0d455de

Please sign in to comment.