Skip to content

Commit 0d455de

Browse files
authored
use BestCompression level for gzip writer
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
1 parent 92b8a71 commit 0d455de

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func writeCompressedFileInfo(w io.Writer, file *fileInfo, r io.Reader) error {
170170
return err
171171
}
172172
sw := &stringWriter{Writer: w}
173-
gw := gzip.NewWriter(sw)
173+
gw, _ := gzip.NewWriterLevel(sw, gzip.BestCompression)
174174
_, err = io.Copy(gw, r)
175175
if err != nil {
176176
return err

test/test_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func Example_compressed() {
114114
// <not compressed>
115115
// /sample-file.txt
116116
// "This file compresses well. Blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah!" <nil>
117-
// "\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"
117+
// "\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"
118118
}
119119

120120
func Example_readTwoOpenedCompressedFiles() {

test/test_vfsdata_test.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)