mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-11 06:10:57 +01:00
Removed output double boffering in deflate wrappermake test
This commit is contained in:
parent
3288124672
commit
c1383793f6
1 changed files with 14 additions and 5 deletions
|
@ -32,7 +32,6 @@ var Deflate = function(options) {
|
|||
}
|
||||
|
||||
this.strm = new zstream();
|
||||
this.strm.next_out = utils.arrayCreate(opt.chunkSize);
|
||||
|
||||
var status = zlib_deflate.deflateInit2(
|
||||
this.strm,
|
||||
|
@ -53,11 +52,13 @@ var Deflate = function(options) {
|
|||
*/
|
||||
Deflate.prototype.push = function(data_in) {
|
||||
var strm = this.strm;
|
||||
var out;
|
||||
var chunkSize = this.options.chunkSize;
|
||||
var sliced;
|
||||
|
||||
strm.next_in = data_in;
|
||||
strm.next_in_index = 0;
|
||||
strm.avail_in = strm.next_in.length;
|
||||
strm.next_out = utils.arrayCreate(chunkSize);
|
||||
|
||||
/* run deflate() on input until output buffer not full, finish
|
||||
compression if all of source has been read in */
|
||||
|
@ -71,9 +72,17 @@ Deflate.prototype.push = function(data_in) {
|
|||
// this.onEnd(ret);
|
||||
//}
|
||||
if(strm.next_out_index) {
|
||||
out = utils.arrayCreate(strm.next_out_index);
|
||||
utils.arraySet(out, strm.next_out, 0, strm.next_out_index, 0);
|
||||
this.onData(out);
|
||||
if (strm.next_out_index === chunkSize) {
|
||||
// out buffer completely filled, push it as is
|
||||
this.onData(strm.next_out);
|
||||
} else {
|
||||
// out buffer partially filled, slice it first
|
||||
sliced = utils.arrayCreate(strm.next_out_index);
|
||||
utils.arraySet(sliced, strm.next_out, 0, strm.next_out_index, 0);
|
||||
this.onData(sliced);
|
||||
}
|
||||
// Allocate buffer for next chunk
|
||||
strm.next_out = utils.arrayCreate(this.options.chunkSize);
|
||||
}
|
||||
} while (strm.avail_in > 0 || strm.avail_out === 0);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue