jung-kurt / gofpdf

A PDF document generator with high level support for text, drawing and images
http://godoc.org/github.com/jung-kurt/gofpdf
MIT License
4.33k stars 780 forks source link

Alternative compression package #32

Open ajstarks opened 9 years ago

ajstarks commented 9 years ago

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?

jung-kurt commented 9 years ago

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.

stanim commented 9 years ago

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).

jung-kurt commented 9 years ago

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.

flibustenet commented 7 years ago

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