Permalink
Browse files

Use zlib defaults.

According to the documentation for deflateInit:

    The WindowBits parameter is the base two logarithm of the window
    size (the size of the history buffer). It should be in the range 9
    through 15. Larger values of this parameter result in better
    compression at the expense of memory usage. The default value is
    15 if deflateInit/2. A negative WindowBits value suppresses the
    zlib header (and checksum) from the stream. Note that the zlib
    source mentions this only as a undocumented feature.

Setting it to 31 made it incompatible with other zlib implementations
(but we're still able to read what was stored before).

Change-Id: I6c21a37a30ef2180ef5fae69231887a59e94b9a4
Reviewed-on: http://review.couchbase.org/11069
Tested-by: Farshid Ghods <farshid.ghods@gmail.com>
Reviewed-by: Dustin Sallings <dustin@spy.net>
  • Loading branch information...
1 parent 8b3b996 commit a7099de2192e428558645a05188f279691a2ea0c @dustin dustin committed Nov 22, 2011
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/couchdb/couch_stream.erl
@@ -154,9 +154,7 @@ gzip_init(Options) ->
case couch_util:get_value(compression_level, Options, 0) of
Lvl when Lvl >= 1 andalso Lvl =< 9 ->
Z = zlib:open(),
- % 15 = ?MAX_WBITS (defined in the zlib module)
- % the 16 + ?MAX_WBITS formula was obtained by inspecting zlib:gzip/1
- ok = zlib:deflateInit(Z, Lvl, deflated, 16 + 15, 8, default),
+ ok = zlib:deflateInit(Z, Lvl),
{
fun(Data) ->
zlib:deflate(Z, Data)
@@ -174,7 +172,7 @@ gzip_init(Options) ->
ungzip_init() ->
Z = zlib:open(),
- zlib:inflateInit(Z, 16 + 15),
+ zlib:inflateInit(Z),
{
fun(Data) ->
zlib:inflate(Z, Data)

0 comments on commit a7099de

Please sign in to comment.