Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/IO/Uncompress/RawInflate.pm |
Statements | Executed 52 statements in 3.49ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 9.00ms | 9.75ms | BEGIN@11 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 1.33ms | 1.68ms | BEGIN@12 | IO::Uncompress::RawInflate::
3 | 1 | 1 | 204µs | 7.10ms | mkUncomp | IO::Uncompress::RawInflate::
1 | 1 | 1 | 25µs | 28µs | BEGIN@4 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 17µs | 233µs | BEGIN@8 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 13µs | 147µs | BEGIN@9 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 11µs | 19µs | BEGIN@5 | IO::Uncompress::RawInflate::
1 | 1 | 1 | 9µs | 12µs | BEGIN@6 | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | _isRaw | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | _isRawx | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | chkTrailer | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | ckMagic | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | ckParams | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | createDeflate | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | getExtraParams | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | inflateSync | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | new | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | rawinflate | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | readHeader | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | scan | IO::Uncompress::RawInflate::
0 | 0 | 0 | 0s | 0s | zap | IO::Uncompress::RawInflate::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package IO::Uncompress::RawInflate ; | ||||
2 | # for RFC1951 | ||||
3 | |||||
4 | 2 | 38µs | 2 | 31µs | # spent 28µs (25+3) within IO::Uncompress::RawInflate::BEGIN@4 which was called:
# once (25µs+3µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 4 # spent 28µs making 1 call to IO::Uncompress::RawInflate::BEGIN@4
# spent 3µs making 1 call to strict::import |
5 | 2 | 29µs | 2 | 27µs | # spent 19µs (11+8) within IO::Uncompress::RawInflate::BEGIN@5 which was called:
# once (11µs+8µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 5 # spent 19µs making 1 call to IO::Uncompress::RawInflate::BEGIN@5
# spent 8µs making 1 call to warnings::import |
6 | 2 | 40µs | 2 | 15µs | # spent 12µs (9+3) within IO::Uncompress::RawInflate::BEGIN@6 which was called:
# once (9µs+3µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 6 # spent 12µs making 1 call to IO::Uncompress::RawInflate::BEGIN@6
# spent 3µs making 1 call to bytes::import |
7 | |||||
8 | 3 | 59µs | 3 | 449µs | # spent 233µs (17+216) within IO::Uncompress::RawInflate::BEGIN@8 which was called:
# once (17µs+216µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 8 # spent 233µs making 1 call to IO::Uncompress::RawInflate::BEGIN@8
# spent 204µs making 1 call to Exporter::import
# spent 12µs making 1 call to version::_VERSION |
9 | 3 | 56µs | 3 | 281µs | # spent 147µs (13+134) within IO::Uncompress::RawInflate::BEGIN@9 which was called:
# once (13µs+134µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 9 # spent 147µs making 1 call to IO::Uncompress::RawInflate::BEGIN@9
# spent 125µs making 1 call to Exporter::import
# spent 9µs making 1 call to version::_VERSION |
10 | |||||
11 | 3 | 568µs | 3 | 9.79ms | # spent 9.75ms (9.00+752µs) within IO::Uncompress::RawInflate::BEGIN@11 which was called:
# once (9.00ms+752µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 11 # spent 9.75ms making 1 call to IO::Uncompress::RawInflate::BEGIN@11
# spent 25µs making 1 call to Exporter::import
# spent 14µs making 1 call to version::_VERSION |
12 | 3 | 2.40ms | 2 | 1.69ms | # spent 1.68ms (1.33+358µs) within IO::Uncompress::RawInflate::BEGIN@12 which was called:
# once (1.33ms+358µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 12 # spent 1.68ms making 1 call to IO::Uncompress::RawInflate::BEGIN@12
# spent 11µs making 1 call to version::_VERSION |
13 | |||||
14 | 1 | 1µs | require Exporter ; | ||
15 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError); | ||||
16 | |||||
17 | 1 | 1µs | $VERSION = '2.074'; | ||
18 | 1 | 1µs | $RawInflateError = ''; | ||
19 | |||||
20 | 1 | 13µs | @ISA = qw(IO::Uncompress::Base Exporter); | ||
21 | 1 | 1µs | @EXPORT_OK = qw( $RawInflateError rawinflate ) ; | ||
22 | 1 | 1µs | %DEFLATE_CONSTANTS = (); | ||
23 | 1 | 2µs | %EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ; | ||
24 | 1 | 1µs | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
25 | 1 | 5µs | 1 | 34µs | Exporter::export_ok_tags('all'); # spent 34µs making 1 call to Exporter::export_ok_tags |
26 | |||||
27 | #{ | ||||
28 | # # Execute at runtime | ||||
29 | # my %bad; | ||||
30 | # for my $module (qw(Compress::Raw::Zlib IO::Compress::Base::Common IO::Uncompress::Base IO::Uncompress::Adapter::Inflate)) | ||||
31 | # { | ||||
32 | # my $ver = ${ $module . "::VERSION"} ; | ||||
33 | # | ||||
34 | # $bad{$module} = $ver | ||||
35 | # if $ver ne $VERSION; | ||||
36 | # } | ||||
37 | # | ||||
38 | # if (keys %bad) | ||||
39 | # { | ||||
40 | # my $string = join "\n", map { "$_ $bad{$_}" } keys %bad; | ||||
41 | # die caller(0)[0] . "needs version $VERSION mismatch\n$string\n"; | ||||
42 | # } | ||||
43 | #} | ||||
44 | |||||
45 | sub new | ||||
46 | { | ||||
47 | my $class = shift ; | ||||
48 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$RawInflateError); | ||||
49 | $obj->_create(undef, 0, @_); | ||||
50 | } | ||||
51 | |||||
52 | sub rawinflate | ||||
53 | { | ||||
54 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$RawInflateError); | ||||
55 | return $obj->_inf(@_); | ||||
56 | } | ||||
57 | |||||
58 | sub getExtraParams | ||||
59 | { | ||||
60 | return (); | ||||
61 | } | ||||
62 | |||||
63 | sub ckParams | ||||
64 | { | ||||
65 | my $self = shift ; | ||||
66 | my $got = shift ; | ||||
67 | |||||
68 | return 1; | ||||
69 | } | ||||
70 | |||||
71 | sub mkUncomp | ||||
72 | # spent 7.10ms (204µs+6.89) within IO::Uncompress::RawInflate::mkUncomp which was called 3 times, avg 2.37ms/call:
# 3 times (204µs+6.89ms) by IO::Uncompress::Base::_create at line 489 of IO/Uncompress/Base.pm, avg 2.37ms/call | ||||
73 | 3 | 12µs | my $self = shift ; | ||
74 | 3 | 2µs | my $got = shift ; | ||
75 | |||||
76 | 3 | 163µs | 12 | 2.80ms | my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject( # spent 2.78ms making 3 calls to IO::Uncompress::Adapter::Inflate::mkUncompObject, avg 928µs/call
# spent 19µs making 9 calls to IO::Compress::Base::Parameters::getValue, avg 2µs/call |
77 | $got->getValue('crc32'), | ||||
78 | $got->getValue('adler32'), | ||||
79 | $got->getValue('scan'), | ||||
80 | ); | ||||
81 | |||||
82 | 3 | 1µs | return $self->saveErrorString(undef, $errstr, $errno) | ||
83 | if ! defined $obj; | ||||
84 | |||||
85 | 3 | 4µs | *$self->{Uncomp} = $obj; | ||
86 | |||||
87 | 3 | 12µs | 3 | 976µs | my $magic = $self->ckMagic() # spent 976µs making 3 calls to IO::Uncompress::Gunzip::ckMagic, avg 325µs/call |
88 | or return 0; | ||||
89 | |||||
90 | 3 | 45µs | 3 | 3.12ms | *$self->{Info} = $self->readHeader($magic) # spent 3.12ms making 3 calls to IO::Uncompress::Gunzip::readHeader, avg 1.04ms/call |
91 | or return undef ; | ||||
92 | |||||
93 | 3 | 18µs | return 1; | ||
94 | |||||
95 | } | ||||
96 | |||||
97 | |||||
98 | sub ckMagic | ||||
99 | { | ||||
100 | my $self = shift; | ||||
101 | |||||
102 | return $self->_isRaw() ; | ||||
103 | } | ||||
104 | |||||
105 | sub readHeader | ||||
106 | { | ||||
107 | my $self = shift; | ||||
108 | my $magic = shift ; | ||||
109 | |||||
110 | return { | ||||
111 | 'Type' => 'rfc1951', | ||||
112 | 'FingerprintLength' => 0, | ||||
113 | 'HeaderLength' => 0, | ||||
114 | 'TrailerLength' => 0, | ||||
115 | 'Header' => '' | ||||
116 | }; | ||||
117 | } | ||||
118 | |||||
119 | sub chkTrailer | ||||
120 | { | ||||
121 | return STATUS_OK ; | ||||
122 | } | ||||
123 | |||||
124 | sub _isRaw | ||||
125 | { | ||||
126 | my $self = shift ; | ||||
127 | |||||
128 | my $got = $self->_isRawx(@_); | ||||
129 | |||||
130 | if ($got) { | ||||
131 | *$self->{Pending} = *$self->{HeaderPending} ; | ||||
132 | } | ||||
133 | else { | ||||
134 | $self->pushBack(*$self->{HeaderPending}); | ||||
135 | *$self->{Uncomp}->reset(); | ||||
136 | } | ||||
137 | *$self->{HeaderPending} = ''; | ||||
138 | |||||
139 | return $got ; | ||||
140 | } | ||||
141 | |||||
142 | sub _isRawx | ||||
143 | { | ||||
144 | my $self = shift ; | ||||
145 | my $magic = shift ; | ||||
146 | |||||
147 | $magic = '' unless defined $magic ; | ||||
148 | |||||
149 | my $buffer = ''; | ||||
150 | |||||
151 | $self->smartRead(\$buffer, *$self->{BlockSize}) >= 0 | ||||
152 | or return $self->saveErrorString(undef, "No data to read"); | ||||
153 | |||||
154 | my $temp_buf = $magic . $buffer ; | ||||
155 | *$self->{HeaderPending} = $temp_buf ; | ||||
156 | $buffer = ''; | ||||
157 | my $status = *$self->{Uncomp}->uncompr(\$temp_buf, \$buffer, $self->smartEof()) ; | ||||
158 | |||||
159 | return $self->saveErrorString(undef, *$self->{Uncomp}{Error}, STATUS_ERROR) | ||||
160 | if $status == STATUS_ERROR; | ||||
161 | |||||
162 | $self->pushBack($temp_buf) ; | ||||
163 | |||||
164 | return $self->saveErrorString(undef, "unexpected end of file", STATUS_ERROR) | ||||
165 | if $self->smartEof() && $status != STATUS_ENDSTREAM; | ||||
166 | |||||
167 | #my $buf_len = *$self->{Uncomp}->uncompressedBytes(); | ||||
168 | my $buf_len = length $buffer; | ||||
169 | |||||
170 | if ($status == STATUS_ENDSTREAM) { | ||||
171 | if (*$self->{MultiStream} | ||||
172 | && (length $temp_buf || ! $self->smartEof())){ | ||||
173 | *$self->{NewStream} = 1 ; | ||||
174 | *$self->{EndStream} = 0 ; | ||||
175 | } | ||||
176 | else { | ||||
177 | *$self->{EndStream} = 1 ; | ||||
178 | } | ||||
179 | } | ||||
180 | *$self->{HeaderPending} = $buffer ; | ||||
181 | *$self->{InflatedBytesRead} = $buf_len ; | ||||
182 | *$self->{TotalInflatedBytesRead} += $buf_len ; | ||||
183 | *$self->{Type} = 'rfc1951'; | ||||
184 | |||||
185 | $self->saveStatus(STATUS_OK); | ||||
186 | |||||
187 | return { | ||||
188 | 'Type' => 'rfc1951', | ||||
189 | 'HeaderLength' => 0, | ||||
190 | 'TrailerLength' => 0, | ||||
191 | 'Header' => '' | ||||
192 | }; | ||||
193 | } | ||||
194 | |||||
195 | |||||
196 | sub inflateSync | ||||
197 | { | ||||
198 | my $self = shift ; | ||||
199 | |||||
200 | # inflateSync is a no-op in Plain mode | ||||
201 | return 1 | ||||
202 | if *$self->{Plain} ; | ||||
203 | |||||
204 | return 0 if *$self->{Closed} ; | ||||
205 | #return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ; | ||||
206 | return 0 if ! length *$self->{Pending} && *$self->{EndStream} ; | ||||
207 | |||||
208 | # Disable CRC check | ||||
209 | *$self->{Strict} = 0 ; | ||||
210 | |||||
211 | my $status ; | ||||
212 | while (1) | ||||
213 | { | ||||
214 | my $temp_buf ; | ||||
215 | |||||
216 | if (length *$self->{Pending} ) | ||||
217 | { | ||||
218 | $temp_buf = *$self->{Pending} ; | ||||
219 | *$self->{Pending} = ''; | ||||
220 | } | ||||
221 | else | ||||
222 | { | ||||
223 | $status = $self->smartRead(\$temp_buf, *$self->{BlockSize}) ; | ||||
224 | return $self->saveErrorString(0, "Error Reading Data") | ||||
225 | if $status < 0 ; | ||||
226 | |||||
227 | if ($status == 0 ) { | ||||
228 | *$self->{EndStream} = 1 ; | ||||
229 | return $self->saveErrorString(0, "unexpected end of file", STATUS_ERROR); | ||||
230 | } | ||||
231 | } | ||||
232 | |||||
233 | $status = *$self->{Uncomp}->sync($temp_buf) ; | ||||
234 | |||||
235 | if ($status == STATUS_OK) | ||||
236 | { | ||||
237 | *$self->{Pending} .= $temp_buf ; | ||||
238 | return 1 ; | ||||
239 | } | ||||
240 | |||||
241 | last unless $status == STATUS_ERROR ; | ||||
242 | } | ||||
243 | |||||
244 | return 0; | ||||
245 | } | ||||
246 | |||||
247 | #sub performScan | ||||
248 | #{ | ||||
249 | # my $self = shift ; | ||||
250 | # | ||||
251 | # my $status ; | ||||
252 | # my $end_offset = 0; | ||||
253 | # | ||||
254 | # $status = $self->scan() | ||||
255 | # #or return $self->saveErrorString(undef, "Error Scanning: $$error_ref", $self->errorNo) ; | ||||
256 | # or return $self->saveErrorString(G_ERR, "Error Scanning: $status") | ||||
257 | # | ||||
258 | # $status = $self->zap($end_offset) | ||||
259 | # or return $self->saveErrorString(G_ERR, "Error Zapping: $status"); | ||||
260 | # #or return $self->saveErrorString(undef, "Error Zapping: $$error_ref", $self->errorNo) ; | ||||
261 | # | ||||
262 | # #(*$obj->{Deflate}, $status) = $inf->createDeflate(); | ||||
263 | # | ||||
264 | ## *$obj->{Header} = *$inf->{Info}{Header}; | ||||
265 | ## *$obj->{UnCompSize_32bit} = | ||||
266 | ## *$obj->{BytesWritten} = *$inf->{UnCompSize_32bit} ; | ||||
267 | ## *$obj->{CompSize_32bit} = *$inf->{CompSize_32bit} ; | ||||
268 | # | ||||
269 | # | ||||
270 | ## if ( $outType eq 'buffer') | ||||
271 | ## { substr( ${ *$self->{Buffer} }, $end_offset) = '' } | ||||
272 | ## elsif ($outType eq 'handle' || $outType eq 'filename') { | ||||
273 | ## *$self->{FH} = *$inf->{FH} ; | ||||
274 | ## delete *$inf->{FH}; | ||||
275 | ## *$obj->{FH}->flush() ; | ||||
276 | ## *$obj->{Handle} = 1 if $outType eq 'handle'; | ||||
277 | ## | ||||
278 | ## #seek(*$obj->{FH}, $end_offset, SEEK_SET) | ||||
279 | ## *$obj->{FH}->seek($end_offset, SEEK_SET) | ||||
280 | ## or return $obj->saveErrorString(undef, $!, $!) ; | ||||
281 | ## } | ||||
282 | # | ||||
283 | #} | ||||
284 | |||||
285 | sub scan | ||||
286 | { | ||||
287 | my $self = shift ; | ||||
288 | |||||
289 | return 1 if *$self->{Closed} ; | ||||
290 | return 1 if !length *$self->{Pending} && *$self->{EndStream} ; | ||||
291 | |||||
292 | my $buffer = '' ; | ||||
293 | my $len = 0; | ||||
294 | |||||
295 | $len = $self->_raw_read(\$buffer, 1) | ||||
296 | while ! *$self->{EndStream} && $len >= 0 ; | ||||
297 | |||||
298 | #return $len if $len < 0 ? $len : 0 ; | ||||
299 | return $len < 0 ? 0 : 1 ; | ||||
300 | } | ||||
301 | |||||
302 | sub zap | ||||
303 | { | ||||
304 | my $self = shift ; | ||||
305 | |||||
306 | my $headerLength = *$self->{Info}{HeaderLength}; | ||||
307 | my $block_offset = $headerLength + *$self->{Uncomp}->getLastBlockOffset(); | ||||
308 | $_[0] = $headerLength + *$self->{Uncomp}->getEndOffset(); | ||||
309 | #printf "# End $_[0], headerlen $headerLength \n";; | ||||
310 | #printf "# block_offset $block_offset %x\n", $block_offset; | ||||
311 | my $byte ; | ||||
312 | ( $self->smartSeek($block_offset) && | ||||
313 | $self->smartRead(\$byte, 1) ) | ||||
314 | or return $self->saveErrorString(0, $!, $!); | ||||
315 | |||||
316 | #printf "#byte is %x\n", unpack('C*',$byte); | ||||
317 | *$self->{Uncomp}->resetLastBlockByte($byte); | ||||
318 | #printf "#to byte is %x\n", unpack('C*',$byte); | ||||
319 | |||||
320 | ( $self->smartSeek($block_offset) && | ||||
321 | $self->smartWrite($byte) ) | ||||
322 | or return $self->saveErrorString(0, $!, $!); | ||||
323 | |||||
324 | #$self->smartSeek($end_offset, 1); | ||||
325 | |||||
326 | return 1 ; | ||||
327 | } | ||||
328 | |||||
329 | sub createDeflate | ||||
330 | { | ||||
331 | my $self = shift ; | ||||
332 | my ($def, $status) = *$self->{Uncomp}->createDeflateStream( | ||||
333 | -AppendOutput => 1, | ||||
334 | -WindowBits => - MAX_WBITS, | ||||
335 | -CRC32 => *$self->{Params}->getValue('crc32'), | ||||
336 | -ADLER32 => *$self->{Params}->getValue('adler32'), | ||||
337 | ); | ||||
338 | |||||
339 | return wantarray ? ($status, $def) : $def ; | ||||
340 | } | ||||
341 | |||||
342 | |||||
343 | 1 | 10µs | 1; | ||
344 | |||||
345 | __END__ |