| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/IO/Uncompress/Inflate.pm |
| Statements | Executed 24 statements in 579µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 754µs | 5.66ms | IO::Uncompress::Inflate::BEGIN@11 |
| 1 | 1 | 1 | 9µs | 10µs | IO::Uncompress::Inflate::BEGIN@4 |
| 1 | 1 | 1 | 7µs | 66µs | IO::Uncompress::Inflate::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 70µs | IO::Uncompress::Inflate::BEGIN@8 |
| 1 | 1 | 1 | 4µs | 5µs | IO::Uncompress::Inflate::BEGIN@6 |
| 1 | 1 | 1 | 4µs | 7µs | IO::Uncompress::Inflate::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::_readDeflateHeader |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::bits |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::chkTrailer |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::ckMagic |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::ckParams |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::getExtraParams |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::inflate |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::isZlibMagic |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::new |
| 0 | 0 | 0 | 0s | 0s | IO::Uncompress::Inflate::readHeader |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package IO::Uncompress::Inflate ; | ||||
| 2 | # for RFC1950 | ||||
| 3 | |||||
| 4 | 2 | 15µs | 2 | 12µs | # spent 10µs (9+2) within IO::Uncompress::Inflate::BEGIN@4 which was called:
# once (9µs+2µs) by Search::Elasticsearch::Role::Cxn::BEGIN@9 at line 4 # spent 10µs making 1 call to IO::Uncompress::Inflate::BEGIN@4
# spent 2µs making 1 call to strict::import |
| 5 | 2 | 12µs | 2 | 10µs | # spent 7µs (4+3) within IO::Uncompress::Inflate::BEGIN@5 which was called:
# once (4µs+3µs) by Search::Elasticsearch::Role::Cxn::BEGIN@9 at line 5 # spent 7µs making 1 call to IO::Uncompress::Inflate::BEGIN@5
# spent 3µs making 1 call to warnings::import |
| 6 | 2 | 15µs | 2 | 6µs | # spent 5µs (4+700ns) within IO::Uncompress::Inflate::BEGIN@6 which was called:
# once (4µs+700ns) by Search::Elasticsearch::Role::Cxn::BEGIN@9 at line 6 # spent 5µs making 1 call to IO::Uncompress::Inflate::BEGIN@6
# spent 700ns making 1 call to bytes::import |
| 7 | |||||
| 8 | 3 | 26µs | 3 | 133µs | # spent 70µs (7+63) within IO::Uncompress::Inflate::BEGIN@8 which was called:
# once (7µs+63µs) by Search::Elasticsearch::Role::Cxn::BEGIN@9 at line 8 # spent 70µs making 1 call to IO::Uncompress::Inflate::BEGIN@8
# spent 58µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
| 9 | 3 | 34µs | 3 | 124µs | # spent 66µs (7+58) within IO::Uncompress::Inflate::BEGIN@9 which was called:
# once (7µs+58µs) by Search::Elasticsearch::Role::Cxn::BEGIN@9 at line 9 # spent 66µs making 1 call to IO::Uncompress::Inflate::BEGIN@9
# spent 54µs making 1 call to Exporter::import
# spent 4µs making 1 call to UNIVERSAL::VERSION |
| 10 | |||||
| 11 | 3 | 463µs | 3 | 5.67ms | # spent 5.66ms (754µs+4.90) within IO::Uncompress::Inflate::BEGIN@11 which was called:
# once (754µs+4.90ms) by Search::Elasticsearch::Role::Cxn::BEGIN@9 at line 11 # spent 5.66ms making 1 call to IO::Uncompress::Inflate::BEGIN@11
# spent 11µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
| 12 | |||||
| 13 | 1 | 300ns | require Exporter ; | ||
| 14 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $InflateError); | ||||
| 15 | |||||
| 16 | 1 | 100ns | $VERSION = '2.068'; | ||
| 17 | 1 | 100ns | $InflateError = ''; | ||
| 18 | |||||
| 19 | 1 | 7µs | @ISA = qw( Exporter IO::Uncompress::RawInflate ); | ||
| 20 | 1 | 400ns | @EXPORT_OK = qw( $InflateError inflate ) ; | ||
| 21 | 1 | 600ns | %EXPORT_TAGS = %IO::Uncompress::RawInflate::DEFLATE_CONSTANTS ; | ||
| 22 | 1 | 800ns | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
| 23 | 1 | 2µs | 1 | 12µs | Exporter::export_ok_tags('all'); # spent 12µs making 1 call to Exporter::export_ok_tags |
| 24 | |||||
| 25 | |||||
| 26 | sub new | ||||
| 27 | { | ||||
| 28 | my $class = shift ; | ||||
| 29 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$InflateError); | ||||
| 30 | |||||
| 31 | $obj->_create(undef, 0, @_); | ||||
| 32 | } | ||||
| 33 | |||||
| 34 | sub inflate | ||||
| 35 | { | ||||
| 36 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$InflateError); | ||||
| 37 | return $obj->_inf(@_); | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | sub getExtraParams | ||||
| 41 | { | ||||
| 42 | return (); | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | sub ckParams | ||||
| 46 | { | ||||
| 47 | my $self = shift ; | ||||
| 48 | my $got = shift ; | ||||
| 49 | |||||
| 50 | # gunzip always needs adler32 | ||||
| 51 | $got->setValue('adler32' => 1); | ||||
| 52 | |||||
| 53 | return 1; | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | sub ckMagic | ||||
| 57 | { | ||||
| 58 | my $self = shift; | ||||
| 59 | |||||
| 60 | my $magic ; | ||||
| 61 | $self->smartReadExact(\$magic, ZLIB_HEADER_SIZE); | ||||
| 62 | |||||
| 63 | *$self->{HeaderPending} = $magic ; | ||||
| 64 | |||||
| 65 | return $self->HeaderError("Header size is " . | ||||
| 66 | ZLIB_HEADER_SIZE . " bytes") | ||||
| 67 | if length $magic != ZLIB_HEADER_SIZE; | ||||
| 68 | |||||
| 69 | #return $self->HeaderError("CRC mismatch.") | ||||
| 70 | return undef | ||||
| 71 | if ! $self->isZlibMagic($magic) ; | ||||
| 72 | |||||
| 73 | *$self->{Type} = 'rfc1950'; | ||||
| 74 | return $magic; | ||||
| 75 | } | ||||
| 76 | |||||
| 77 | sub readHeader | ||||
| 78 | { | ||||
| 79 | my $self = shift; | ||||
| 80 | my $magic = shift ; | ||||
| 81 | |||||
| 82 | return $self->_readDeflateHeader($magic) ; | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | sub chkTrailer | ||||
| 86 | { | ||||
| 87 | my $self = shift; | ||||
| 88 | my $trailer = shift; | ||||
| 89 | |||||
| 90 | my $ADLER32 = unpack("N", $trailer) ; | ||||
| 91 | *$self->{Info}{ADLER32} = $ADLER32; | ||||
| 92 | return $self->TrailerError("CRC mismatch") | ||||
| 93 | if *$self->{Strict} && $ADLER32 != *$self->{Uncomp}->adler32() ; | ||||
| 94 | |||||
| 95 | return STATUS_OK; | ||||
| 96 | } | ||||
| 97 | |||||
| - - | |||||
| 100 | sub isZlibMagic | ||||
| 101 | { | ||||
| 102 | my $self = shift; | ||||
| 103 | my $buffer = shift ; | ||||
| 104 | |||||
| 105 | return 0 | ||||
| 106 | if length $buffer < ZLIB_HEADER_SIZE ; | ||||
| 107 | |||||
| 108 | my $hdr = unpack("n", $buffer) ; | ||||
| 109 | #return 0 if $hdr % 31 != 0 ; | ||||
| 110 | return $self->HeaderError("CRC mismatch.") | ||||
| 111 | if $hdr % 31 != 0 ; | ||||
| 112 | |||||
| 113 | my ($CMF, $FLG) = unpack "C C", $buffer; | ||||
| 114 | my $cm = bits($CMF, ZLIB_CMF_CM_OFFSET, ZLIB_CMF_CM_BITS) ; | ||||
| 115 | |||||
| 116 | # Only Deflate supported | ||||
| 117 | return $self->HeaderError("Not Deflate (CM is $cm)") | ||||
| 118 | if $cm != ZLIB_CMF_CM_DEFLATED ; | ||||
| 119 | |||||
| 120 | # Max window value is 7 for Deflate. | ||||
| 121 | my $cinfo = bits($CMF, ZLIB_CMF_CINFO_OFFSET, ZLIB_CMF_CINFO_BITS) ; | ||||
| 122 | return $self->HeaderError("CINFO > " . ZLIB_CMF_CINFO_MAX . | ||||
| 123 | " (CINFO is $cinfo)") | ||||
| 124 | if $cinfo > ZLIB_CMF_CINFO_MAX ; | ||||
| 125 | |||||
| 126 | return 1; | ||||
| 127 | } | ||||
| 128 | |||||
| 129 | sub bits | ||||
| 130 | { | ||||
| 131 | my $data = shift ; | ||||
| 132 | my $offset = shift ; | ||||
| 133 | my $mask = shift ; | ||||
| 134 | |||||
| 135 | ($data >> $offset ) & $mask & 0xFF ; | ||||
| 136 | } | ||||
| 137 | |||||
| 138 | |||||
| 139 | sub _readDeflateHeader | ||||
| 140 | { | ||||
| 141 | my ($self, $buffer) = @_ ; | ||||
| 142 | |||||
| 143 | # if (! $buffer) { | ||||
| 144 | # $self->smartReadExact(\$buffer, ZLIB_HEADER_SIZE); | ||||
| 145 | # | ||||
| 146 | # *$self->{HeaderPending} = $buffer ; | ||||
| 147 | # | ||||
| 148 | # return $self->HeaderError("Header size is " . | ||||
| 149 | # ZLIB_HEADER_SIZE . " bytes") | ||||
| 150 | # if length $buffer != ZLIB_HEADER_SIZE; | ||||
| 151 | # | ||||
| 152 | # return $self->HeaderError("CRC mismatch.") | ||||
| 153 | # if ! isZlibMagic($buffer) ; | ||||
| 154 | # } | ||||
| 155 | |||||
| 156 | my ($CMF, $FLG) = unpack "C C", $buffer; | ||||
| 157 | my $FDICT = bits($FLG, ZLIB_FLG_FDICT_OFFSET, ZLIB_FLG_FDICT_BITS ), | ||||
| 158 | |||||
| 159 | my $cm = bits($CMF, ZLIB_CMF_CM_OFFSET, ZLIB_CMF_CM_BITS) ; | ||||
| 160 | $cm == ZLIB_CMF_CM_DEFLATED | ||||
| 161 | or return $self->HeaderError("Not Deflate (CM is $cm)") ; | ||||
| 162 | |||||
| 163 | my $DICTID; | ||||
| 164 | if ($FDICT) { | ||||
| 165 | $self->smartReadExact(\$buffer, ZLIB_FDICT_SIZE) | ||||
| 166 | or return $self->TruncatedHeader("FDICT"); | ||||
| 167 | |||||
| 168 | $DICTID = unpack("N", $buffer) ; | ||||
| 169 | } | ||||
| 170 | |||||
| 171 | *$self->{Type} = 'rfc1950'; | ||||
| 172 | |||||
| 173 | return { | ||||
| 174 | 'Type' => 'rfc1950', | ||||
| 175 | 'FingerprintLength' => ZLIB_HEADER_SIZE, | ||||
| 176 | 'HeaderLength' => ZLIB_HEADER_SIZE, | ||||
| 177 | 'TrailerLength' => ZLIB_TRAILER_SIZE, | ||||
| 178 | 'Header' => $buffer, | ||||
| 179 | |||||
| 180 | CMF => $CMF , | ||||
| 181 | CM => bits($CMF, ZLIB_CMF_CM_OFFSET, ZLIB_CMF_CM_BITS ), | ||||
| 182 | CINFO => bits($CMF, ZLIB_CMF_CINFO_OFFSET, ZLIB_CMF_CINFO_BITS ), | ||||
| 183 | FLG => $FLG , | ||||
| 184 | FCHECK => bits($FLG, ZLIB_FLG_FCHECK_OFFSET, ZLIB_FLG_FCHECK_BITS), | ||||
| 185 | FDICT => bits($FLG, ZLIB_FLG_FDICT_OFFSET, ZLIB_FLG_FDICT_BITS ), | ||||
| 186 | FLEVEL => bits($FLG, ZLIB_FLG_LEVEL_OFFSET, ZLIB_FLG_LEVEL_BITS ), | ||||
| 187 | DICTID => $DICTID , | ||||
| 188 | |||||
| 189 | }; | ||||
| 190 | } | ||||
| 191 | |||||
| - - | |||||
| 195 | 1 | 5µs | 1 ; | ||
| 196 | |||||
| 197 | __END__ |