http_out($_[0])->write(translate($_[0], $_[1]));
}
+sub zadd {
+ my $self = shift;
+ $self->{pbuf} .= $_ for @_; # perl internal pad memory use here
+}
+
# similar to ->translate; use this when we're sure we know we have
# more data to buffer after this
sub zmore {
- my $self = $_[0]; # $_[1] => input
+ my $self = shift; # $_[1] => input
http_out($self);
- my $err;
- for (delete $self->{obuf}, @_[1..$#_]) {
- $err = $self->{gz}->deflate($_ // next, $self->{zbuf});
- die "gzip->deflate: $err" if $err != Z_OK;
+ my $x;
+ defined($x = delete($self->{pbuf})) and unshift(@_, $x);
+ for (@_) {
+ ($x = $self->{gz}->deflate($_, $self->{zbuf})) == Z_OK or
+ die "gzip->deflate: $x";
}
undef;
}
# flushes and returns the final bit of gzipped data
sub zflush ($;@) {
- my $self = $_[0]; # $_[1..Inf] => final input (optional)
+ my $self = shift; # $_[1..Inf] => final input (optional)
my $zbuf = delete $self->{zbuf};
my $gz = delete $self->{gz};
- my $err;
- # it's a bug iff $gz is undef w/ $obuf or $_[1..]
- for (delete $self->{obuf}, @_[1..$#_]) {
- $err = $gz->deflate($_ // next, $zbuf);
- die "gzip->deflate: $err" if $err != Z_OK;
+ my $x;
+ defined($x = delete($self->{pbuf})) and unshift(@_, $x);
+ for (@_) { # it's a bug iff $gz is undef if @_ isn't empty, here:
+ ($x = $gz->deflate($_, $zbuf)) == Z_OK or
+ die "gzip->deflate: $x";
}
$gz // return ''; # not a bug, recursing on DS->write failure
- $err = $gz->flush($zbuf);
- die "gzip->flush: $err" if $err != Z_OK;
+ ($x = $gz->flush($zbuf)) == Z_OK or die "gzip->flush: $x";
$zbuf;
}