← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:20 2013

Filename/usr/lib/perl/5.10/IO/Uncompress/RawInflate.pm
StatementsExecuted 32 statements in 1.93ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118.54ms9.99msIO::Uncompress::RawInflate::::BEGIN@11IO::Uncompress::RawInflate::BEGIN@11
111986µs1.51msIO::Uncompress::RawInflate::::BEGIN@12IO::Uncompress::RawInflate::BEGIN@12
11128µs414µsIO::Uncompress::RawInflate::::BEGIN@8IO::Uncompress::RawInflate::BEGIN@8
11119µs23µsIO::Uncompress::RawInflate::::BEGIN@4IO::Uncompress::RawInflate::BEGIN@4
11117µs220µsIO::Uncompress::RawInflate::::BEGIN@9IO::Uncompress::RawInflate::BEGIN@9
11112µs16µsIO::Uncompress::RawInflate::::BEGIN@6IO::Uncompress::RawInflate::BEGIN@6
11112µs25µsIO::Uncompress::RawInflate::::BEGIN@5IO::Uncompress::RawInflate::BEGIN@5
0000s0sIO::Uncompress::RawInflate::::_isRawIO::Uncompress::RawInflate::_isRaw
0000s0sIO::Uncompress::RawInflate::::_isRawxIO::Uncompress::RawInflate::_isRawx
0000s0sIO::Uncompress::RawInflate::::chkTrailerIO::Uncompress::RawInflate::chkTrailer
0000s0sIO::Uncompress::RawInflate::::ckMagicIO::Uncompress::RawInflate::ckMagic
0000s0sIO::Uncompress::RawInflate::::ckParamsIO::Uncompress::RawInflate::ckParams
0000s0sIO::Uncompress::RawInflate::::createDeflateIO::Uncompress::RawInflate::createDeflate
0000s0sIO::Uncompress::RawInflate::::getExtraParamsIO::Uncompress::RawInflate::getExtraParams
0000s0sIO::Uncompress::RawInflate::::inflateSyncIO::Uncompress::RawInflate::inflateSync
0000s0sIO::Uncompress::RawInflate::::mkUncompIO::Uncompress::RawInflate::mkUncomp
0000s0sIO::Uncompress::RawInflate::::newIO::Uncompress::RawInflate::new
0000s0sIO::Uncompress::RawInflate::::rawinflateIO::Uncompress::RawInflate::rawinflate
0000s0sIO::Uncompress::RawInflate::::readHeaderIO::Uncompress::RawInflate::readHeader
0000s0sIO::Uncompress::RawInflate::::scanIO::Uncompress::RawInflate::scan
0000s0sIO::Uncompress::RawInflate::::zapIO::Uncompress::RawInflate::zap
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package IO::Uncompress::RawInflate ;
2# for RFC1951
3
4328µs227µs
# spent 23µs (19+4) within IO::Uncompress::RawInflate::BEGIN@4 which was called: # once (19µs+4µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 4
use strict ;
# spent 23µs making 1 call to IO::Uncompress::RawInflate::BEGIN@4 # spent 4µs making 1 call to strict::import
5341µs239µs
# spent 25µs (12+14) within IO::Uncompress::RawInflate::BEGIN@5 which was called: # once (12µs+14µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 5
use warnings;
# spent 25µs making 1 call to IO::Uncompress::RawInflate::BEGIN@5 # spent 14µs making 1 call to warnings::import
6347µs219µs
# spent 16µs (12+4) within IO::Uncompress::RawInflate::BEGIN@6 which was called: # once (12µs+4µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 6
use bytes;
# spent 16µs making 1 call to IO::Uncompress::RawInflate::BEGIN@6 # spent 4µs making 1 call to bytes::import
7
8374µs3800µs
# spent 414µs (28+386) within IO::Uncompress::RawInflate::BEGIN@8 which was called: # once (28µs+386µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 8
use Compress::Raw::Zlib 2.020 ;
# spent 414µs making 1 call to IO::Uncompress::RawInflate::BEGIN@8 # spent 366µs making 1 call to Exporter::import # spent 20µs making 1 call to UNIVERSAL::VERSION
9362µs3422µs
# spent 220µs (17+202) within IO::Uncompress::RawInflate::BEGIN@9 which was called: # once (17µs+202µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 9
use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject);
# spent 220µs making 1 call to IO::Uncompress::RawInflate::BEGIN@9 # spent 186µs making 1 call to Exporter::import # spent 16µs making 1 call to UNIVERSAL::VERSION
10
113234µs310.1ms
# spent 9.99ms (8.54+1.45) within IO::Uncompress::RawInflate::BEGIN@11 which was called: # once (8.54ms+1.45ms) by IO::Uncompress::Gunzip::BEGIN@12 at line 11
use IO::Uncompress::Base 2.020 ;
# spent 9.99ms making 1 call to IO::Uncompress::RawInflate::BEGIN@11 # spent 63µs making 1 call to Exporter::import # spent 29µs making 1 call to UNIVERSAL::VERSION
1231.39ms21.52ms
# spent 1.51ms (986µs+522µs) within IO::Uncompress::RawInflate::BEGIN@12 which was called: # once (986µs+522µs) by IO::Uncompress::Gunzip::BEGIN@12 at line 12
use IO::Uncompress::Adapter::Inflate 2.020 ;
# spent 1.51ms making 1 call to IO::Uncompress::RawInflate::BEGIN@12 # spent 16µs making 1 call to UNIVERSAL::VERSION
13
1411µsrequire Exporter ;
1511µsour ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError);
16
171900ns$VERSION = '2.020';
181300ns$RawInflateError = '';
19
20124µs@ISA = qw( Exporter IO::Uncompress::Base );
2111µs@EXPORT_OK = qw( $RawInflateError rawinflate ) ;
221500ns%DEFLATE_CONSTANTS = ();
2312µs%EXPORT_TAGS = %IO::Uncompress::Base::EXPORT_TAGS ;
2412µspush @{ $EXPORT_TAGS{all} }, @EXPORT_OK ;
2514µs129µsExporter::export_ok_tags('all');
# spent 29µ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
45sub new
46{
47 my $class = shift ;
48 my $obj = createSelfTiedObject($class, \$RawInflateError);
49 $obj->_create(undef, 0, @_);
50}
51
52sub rawinflate
53{
54 my $obj = createSelfTiedObject(undef, \$RawInflateError);
55 return $obj->_inf(@_);
56}
57
58sub getExtraParams
59{
60 return ();
61}
62
63sub ckParams
64{
65 my $self = shift ;
66 my $got = shift ;
67
68 return 1;
69}
70
71sub mkUncomp
72{
73 my $self = shift ;
74 my $got = shift ;
75
76 my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::Inflate::mkUncompObject(
77 $got->value('CRC32'),
78 $got->value('ADLER32'),
79 $got->value('Scan'),
80 );
81
82 return $self->saveErrorString(undef, $errstr, $errno)
83 if ! defined $obj;
84
85 *$self->{Uncomp} = $obj;
86
87 my $magic = $self->ckMagic()
88 or return 0;
89
90 *$self->{Info} = $self->readHeader($magic)
91 or return undef ;
92
93 return 1;
94
95}
96
97
98sub ckMagic
99{
100 my $self = shift;
101
102 return $self->_isRaw() ;
103}
104
105sub 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
119sub chkTrailer
120{
121 return STATUS_OK ;
122}
123
124sub _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
142sub _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
196sub 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
285sub 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
302sub 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
329sub createDeflate
330{
331 my $self = shift ;
332 my ($def, $status) = *$self->{Uncomp}->createDeflateStream(
333 -AppendOutput => 1,
334 -WindowBits => - MAX_WBITS,
335 -CRC32 => *$self->{Params}->value('CRC32'),
336 -ADLER32 => *$self->{Params}->value('ADLER32'),
337 );
338
339 return wantarray ? ($status, $def) : $def ;
340}
341
342
343110µs1;
344
345__END__