gofpdf icon indicating copy to clipboard operation
gofpdf copied to clipboard

Alternative compression package

Open ajstarks opened this issue 10 years ago • 4 comments

See: http://blog.klauspost.com/optimized-gzipzip-packages-30-50-faster/ --- a drop in replacement for Go's standard compression package.

As an experiment, I've used it on in font.go and util.go, and indeed for my application, pdfdeck, builds are a bit faster on my MacBook AIr (1.4 vs 1.3 seconds to build a image-heavy presentation).

Any interest?

ajstarks avatar Jul 28 '15 15:07 ajstarks

Looks like a lot of nice improvements. The author writes:

I will probably tidy up the crc32 optimization and submit it to Go to be part of the standard library.

I am inclined to wait until this happens. One of the nice features of gofpdf currently is that it depends only on the Go standard library.

jung-kurt avatar Jul 28 '15 15:07 jung-kurt

I also like that gofpdf only depends on the Go standard library. If these new compression packages don't make it to the standard library, perhaps we could define the compression through an interface to allow different implementations (with the go stdlib as the default).

stanim avatar Jul 29 '15 20:07 stanim

perhaps we could define the compression through an interface to allow different implementations

Excellent idea. It looks to me like the interface would be as simple as

type Compressor interface {
  Compress([]byte) ([]byte, error)
  Uncompress([]byte) []byte
}

A new method, SetCompressor(cmp Compressor), could be used to register the implementation.

jung-kurt avatar Jul 30 '15 12:07 jung-kurt

I think a part of the work of @klauspost is now in Go 1.7

flibustenet avatar Oct 02 '16 17:10 flibustenet