Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/IO/Uncompress/Base.pm |
Statements | Executed 102913 statements in 99.7ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
631 | 2 | 1 | 17.0ms | 114ms | _raw_read | IO::Uncompress::Base::
1356 | 4 | 1 | 15.8ms | 26.9ms | smartRead | IO::Uncompress::Base::
645 | 3 | 1 | 13.0ms | 26.6ms | smartEof | IO::Uncompress::Base::
635 | 2 | 2 | 10.5ms | 125ms | read | IO::Uncompress::Base::
1222 | 2 | 1 | 5.54ms | 5.54ms | pushBack | IO::Uncompress::Base::
1991 | 4 | 1 | 4.94ms | 4.94ms | saveStatus | IO::Uncompress::Base::
2539 | 3 | 1 | 4.19ms | 4.49ms | eof | IO::Uncompress::Base::
631 | 1 | 1 | 2.58ms | 18.2ms | readBlock | IO::Uncompress::Base::
645 | 1 | 1 | 1.43ms | 1.43ms | getErrInfo | IO::Uncompress::Base::
1271 | 1 | 1 | 1.43ms | 1.43ms | errorNo | IO::Uncompress::Base::
645 | 1 | 1 | 1.38ms | 1.38ms | setErrInfo | IO::Uncompress::Base::
3 | 1 | 1 | 901µs | 12.8ms | _create | IO::Uncompress::Base::
631 | 1 | 1 | 577µs | 577µs | filterUncompressed | IO::Uncompress::Base::
631 | 1 | 1 | 531µs | 531µs | postBlockChk | IO::Uncompress::Base::
78 | 3 | 1 | 441µs | 2.91ms | smartReadExact | IO::Uncompress::Base::
3 | 1 | 1 | 258µs | 898µs | checkParams | IO::Uncompress::Base::
6 | 2 | 2 | 162µs | 253µs | close | IO::Uncompress::Base::
3 | 1 | 1 | 91µs | 91µs | TIEHANDLE | IO::Uncompress::Base::
3 | 1 | 1 | 73µs | 143µs | ckInputParam | IO::Uncompress::Base::
3 | 2 | 2 | 54µs | 60µs | DESTROY | IO::Uncompress::Base::
3 | 1 | 1 | 40µs | 40µs | ungetc | IO::Uncompress::Base::
1 | 1 | 1 | 27µs | 52µs | BEGIN@428 | IO::Uncompress::Base::
1 | 1 | 1 | 22µs | 24µs | BEGIN@4 | IO::Uncompress::Base::
1 | 1 | 1 | 18µs | 181µs | BEGIN@17 | IO::Uncompress::Base::
6 | 6 | 1 | 16µs | 16µs | _notAvailable | IO::Uncompress::Base::
1 | 1 | 1 | 15µs | 172µs | BEGIN@19 | IO::Uncompress::Base::
1 | 1 | 1 | 14µs | 56µs | BEGIN@20 | IO::Uncompress::Base::
1 | 1 | 1 | 12µs | 30µs | BEGIN@90 | IO::Uncompress::Base::
1 | 1 | 1 | 10µs | 17µs | BEGIN@5 | IO::Uncompress::Base::
1 | 1 | 1 | 9µs | 59µs | BEGIN@14 | IO::Uncompress::Base::
1 | 1 | 1 | 9µs | 12µs | BEGIN@6 | IO::Uncompress::Base::
1 | 1 | 1 | 8µs | 45µs | BEGIN@15 | IO::Uncompress::Base::
1 | 1 | 1 | 8µs | 39µs | BEGIN@23 | IO::Uncompress::Base::
1 | 1 | 1 | 5µs | 5µs | BEGIN@21 | IO::Uncompress::Base::
1 | 1 | 1 | 5µs | 5µs | BEGIN@22 | IO::Uncompress::Base::
3 | 1 | 1 | 5µs | 5µs | UNTIE | IO::Uncompress::Base::
3 | 1 | 1 | 5µs | 5µs | postCheckParams | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | HeaderError | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | READLINE | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | TrailerError | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | TruncatedHeader | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | TruncatedTrailer | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | __ANON__[:1497] | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | _getline | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | _inf | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | _rd2 | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | _singleTarget | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | autoflush | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | binmode | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | clearError | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | closeError | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | croakError | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | error | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | fileno | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | getHeaderInfo | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | getc | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | getline | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | getlines | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | gotoNextStream | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | input_line_number | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | nextStream | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | opened | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | reset | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | retErr | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | saveErrorString | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | seek | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | smartSeek | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | smartTell | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | smartWrite | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | streamCount | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | tell | IO::Uncompress::Base::
0 | 0 | 0 | 0s | 0s | trailingData | IO::Uncompress::Base::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package IO::Uncompress::Base ; | ||||
3 | |||||
4 | 2 | 32µs | 2 | 26µs | # spent 24µs (22+2) within IO::Uncompress::Base::BEGIN@4 which was called:
# once (22µs+2µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 4 # spent 24µs making 1 call to IO::Uncompress::Base::BEGIN@4
# spent 2µs making 1 call to strict::import |
5 | 2 | 36µs | 2 | 24µs | # spent 17µs (10+7) within IO::Uncompress::Base::BEGIN@5 which was called:
# once (10µs+7µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 5 # spent 17µs making 1 call to IO::Uncompress::Base::BEGIN@5
# spent 7µs making 1 call to warnings::import |
6 | 2 | 79µs | 2 | 15µs | # spent 12µs (9+3) within IO::Uncompress::Base::BEGIN@6 which was called:
# once (9µs+3µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 6 # spent 12µs making 1 call to IO::Uncompress::Base::BEGIN@6
# spent 3µs making 1 call to bytes::import |
7 | |||||
8 | our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS); | ||||
9 | 1 | 18µs | @ISA = qw(IO::File Exporter); | ||
10 | |||||
11 | |||||
12 | 1 | 1µs | $VERSION = '2.074'; | ||
13 | |||||
14 | 2 | 35µs | 2 | 109µs | # spent 59µs (9+50) within IO::Uncompress::Base::BEGIN@14 which was called:
# once (9µs+50µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 14 # spent 59µs making 1 call to IO::Uncompress::Base::BEGIN@14
# spent 50µs making 1 call to constant::import |
15 | 2 | 36µs | 2 | 82µs | # spent 45µs (8+37) within IO::Uncompress::Base::BEGIN@15 which was called:
# once (8µs+37µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 15 # spent 45µs making 1 call to IO::Uncompress::Base::BEGIN@15
# spent 37µs making 1 call to constant::import |
16 | |||||
17 | 3 | 50µs | 3 | 344µs | # spent 181µs (18+163) within IO::Uncompress::Base::BEGIN@17 which was called:
# once (18µs+163µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 17 # spent 181µs making 1 call to IO::Uncompress::Base::BEGIN@17
# spent 153µs making 1 call to Exporter::import
# spent 10µs making 1 call to version::_VERSION |
18 | |||||
19 | 2 | 36µs | 2 | 329µs | # spent 172µs (15+157) within IO::Uncompress::Base::BEGIN@19 which was called:
# once (15µs+157µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 19 # spent 172µs making 1 call to IO::Uncompress::Base::BEGIN@19
# spent 157µs making 1 call to Exporter::import |
20 | 2 | 33µs | 2 | 98µs | # spent 56µs (14+42) within IO::Uncompress::Base::BEGIN@20 which was called:
# once (14µs+42µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 20 # spent 56µs making 1 call to IO::Uncompress::Base::BEGIN@20
# spent 42µs making 1 call to Exporter::import |
21 | 2 | 32µs | 1 | 5µs | # spent 5µs within IO::Uncompress::Base::BEGIN@21 which was called:
# once (5µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 21 # spent 5µs making 1 call to IO::Uncompress::Base::BEGIN@21 |
22 | 2 | 25µs | 1 | 5µs | # spent 5µs within IO::Uncompress::Base::BEGIN@22 which was called:
# once (5µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 22 # spent 5µs making 1 call to IO::Uncompress::Base::BEGIN@22 |
23 | 2 | 325µs | 2 | 70µs | # spent 39µs (8+31) within IO::Uncompress::Base::BEGIN@23 which was called:
# once (8µs+31µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 23 # spent 39µs making 1 call to IO::Uncompress::Base::BEGIN@23
# spent 31µs making 1 call to Exporter::import |
24 | |||||
25 | 1 | 0s | %EXPORT_TAGS = ( ); | ||
26 | 1 | 2µs | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
27 | |||||
28 | sub smartRead | ||||
29 | # spent 26.9ms (15.8+11.1) within IO::Uncompress::Base::smartRead which was called 1356 times, avg 20µs/call:
# 645 times (5.16ms+3.74ms) by IO::Uncompress::Base::smartEof at line 219, avg 14µs/call
# 631 times (9.44ms+6.14ms) by IO::Uncompress::Base::readBlock at line 836, avg 25µs/call
# 78 times (1.23ms+1.24ms) by IO::Uncompress::Base::smartReadExact at line 195, avg 32µs/call
# 2 times (8µs+0s) by IO::Uncompress::Base::_raw_read at line 949, avg 4µs/call | ||||
30 | 1356 | 245µs | my $self = $_[0]; | ||
31 | 1356 | 210µs | my $out = $_[1]; | ||
32 | 1356 | 168µs | my $size = $_[2]; | ||
33 | 1356 | 334µs | $$out = "" ; | ||
34 | |||||
35 | 1356 | 151µs | my $offset = 0 ; | ||
36 | 1356 | 149µs | my $status = 1; | ||
37 | |||||
38 | |||||
39 | 1356 | 396µs | if (defined *$self->{InputLength}) { | ||
40 | return 0 | ||||
41 | if *$self->{InputLengthRemaining} <= 0 ; | ||||
42 | $size = List::Util::min($size, *$self->{InputLengthRemaining}); | ||||
43 | } | ||||
44 | |||||
45 | 1356 | 416µs | if ( length *$self->{Prime} ) { | ||
46 | 630 | 1.68ms | $$out = substr(*$self->{Prime}, 0, $size) ; | ||
47 | 630 | 291µs | substr(*$self->{Prime}, 0, $size) = '' ; | ||
48 | 630 | 177µs | if (length $$out == $size) { | ||
49 | *$self->{InputLengthRemaining} -= length $$out | ||||
50 | 2 | 0s | if defined *$self->{InputLength}; | ||
51 | |||||
52 | 2 | 8µs | return length $$out ; | ||
53 | } | ||||
54 | 628 | 98µs | $offset = length $$out ; | ||
55 | } | ||||
56 | |||||
57 | 1354 | 332µs | my $get_size = $size - $offset ; | ||
58 | |||||
59 | 1354 | 574µs | if (defined *$self->{FH}) { | ||
60 | 1354 | 349µs | if ($offset) { | ||
61 | # Not using this | ||||
62 | # | ||||
63 | # *$self->{FH}->read($$out, $get_size, $offset); | ||||
64 | # | ||||
65 | # because the filehandle may not support the offset parameter | ||||
66 | # An example is Net::FTP | ||||
67 | 628 | 138µs | my $tmp = ''; | ||
68 | 628 | 973µs | 628 | 3.99ms | $status = *$self->{FH}->read($tmp, $get_size) ; # spent 3.99ms making 628 calls to IO::Handle::read, avg 6µs/call |
69 | 628 | 1.48ms | substr($$out, $offset) = $tmp | ||
70 | if defined $status && $status > 0 ; | ||||
71 | } | ||||
72 | else | ||||
73 | 726 | 1.09ms | 726 | 3.67ms | { $status = *$self->{FH}->read($$out, $get_size) } # spent 3.67ms making 726 calls to IO::Handle::read, avg 5µs/call |
74 | } | ||||
75 | elsif (defined *$self->{InputEvent}) { | ||||
76 | my $got = 1 ; | ||||
77 | while (length $$out < $size) { | ||||
78 | last | ||||
79 | if ($got = *$self->{InputEvent}->($$out, $get_size)) <= 0; | ||||
80 | } | ||||
81 | |||||
82 | if (length $$out > $size ) { | ||||
83 | *$self->{Prime} = substr($$out, $size, length($$out)); | ||||
84 | substr($$out, $size, length($$out)) = ''; | ||||
85 | } | ||||
86 | |||||
87 | *$self->{EventEof} = 1 if $got <= 0 ; | ||||
88 | } | ||||
89 | else { | ||||
90 | 2 | 2.30ms | 2 | 48µs | # spent 30µs (12+18) within IO::Uncompress::Base::BEGIN@90 which was called:
# once (12µs+18µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 90 # spent 30µs making 1 call to IO::Uncompress::Base::BEGIN@90
# spent 18µs making 1 call to warnings::unimport |
91 | my $buf = *$self->{Buffer} ; | ||||
92 | $$buf = '' unless defined $$buf ; | ||||
93 | substr($$out, $offset) = substr($$buf, *$self->{BufferOffset}, $get_size); | ||||
94 | if (*$self->{ConsumeInput}) | ||||
95 | { substr($$buf, 0, $get_size) = '' } | ||||
96 | else | ||||
97 | { *$self->{BufferOffset} += length($$out) - $offset } | ||||
98 | } | ||||
99 | |||||
100 | *$self->{InputLengthRemaining} -= length($$out) #- $offset | ||||
101 | 1354 | 576µs | if defined *$self->{InputLength}; | ||
102 | |||||
103 | 1354 | 219µs | if (! defined $status) { | ||
104 | $self->saveStatus($!) ; | ||||
105 | return STATUS_ERROR; | ||||
106 | } | ||||
107 | |||||
108 | 1354 | 2.17ms | 1354 | 3.45ms | $self->saveStatus(length $$out < 0 ? STATUS_ERROR : STATUS_OK) ; # spent 3.45ms making 1354 calls to IO::Uncompress::Base::saveStatus, avg 3µs/call |
109 | |||||
110 | 1354 | 2.65ms | return length $$out; | ||
111 | } | ||||
112 | |||||
113 | sub pushBack | ||||
114 | { | ||||
115 | 1222 | 246µs | my $self = shift ; | ||
116 | |||||
117 | 1222 | 599µs | return if ! defined $_[0] || length $_[0] == 0 ; | ||
118 | |||||
119 | 1222 | 2.92ms | if (defined *$self->{FH} || defined *$self->{InputEvent} ) { | ||
120 | 1222 | 2.57ms | *$self->{Prime} = $_[0] . *$self->{Prime} ; | ||
121 | 1222 | 470µs | *$self->{InputLengthRemaining} += length($_[0]); | ||
122 | } | ||||
123 | else { | ||||
124 | my $len = length $_[0]; | ||||
125 | |||||
126 | if($len > *$self->{BufferOffset}) { | ||||
127 | *$self->{Prime} = substr($_[0], 0, $len - *$self->{BufferOffset}) . *$self->{Prime} ; | ||||
128 | *$self->{InputLengthRemaining} = *$self->{InputLength}; | ||||
129 | *$self->{BufferOffset} = 0 | ||||
130 | } | ||||
131 | else { | ||||
132 | *$self->{InputLengthRemaining} += length($_[0]); | ||||
133 | *$self->{BufferOffset} -= length($_[0]) ; | ||||
134 | } | ||||
135 | } | ||||
136 | } | ||||
137 | |||||
138 | sub smartSeek | ||||
139 | { | ||||
140 | my $self = shift ; | ||||
141 | my $offset = shift ; | ||||
142 | my $truncate = shift; | ||||
143 | my $position = shift || SEEK_SET; | ||||
144 | |||||
145 | # TODO -- need to take prime into account | ||||
146 | if (defined *$self->{FH}) | ||||
147 | { *$self->{FH}->seek($offset, $position) } | ||||
148 | else { | ||||
149 | if ($position == SEEK_END) { | ||||
150 | *$self->{BufferOffset} = length ${ *$self->{Buffer} } + $offset ; | ||||
151 | } | ||||
152 | elsif ($position == SEEK_CUR) { | ||||
153 | *$self->{BufferOffset} += $offset ; | ||||
154 | } | ||||
155 | else { | ||||
156 | *$self->{BufferOffset} = $offset ; | ||||
157 | } | ||||
158 | |||||
159 | substr(${ *$self->{Buffer} }, *$self->{BufferOffset}) = '' | ||||
160 | if $truncate; | ||||
161 | return 1; | ||||
162 | } | ||||
163 | } | ||||
164 | |||||
165 | sub smartTell | ||||
166 | { | ||||
167 | my $self = shift ; | ||||
168 | |||||
169 | if (defined *$self->{FH}) | ||||
170 | { return *$self->{FH}->tell() } | ||||
171 | else | ||||
172 | { return *$self->{BufferOffset} } | ||||
173 | } | ||||
174 | |||||
175 | sub smartWrite | ||||
176 | { | ||||
177 | my $self = shift ; | ||||
178 | my $out_data = shift ; | ||||
179 | |||||
180 | if (defined *$self->{FH}) { | ||||
181 | # flush needed for 5.8.0 | ||||
182 | defined *$self->{FH}->write($out_data, length $out_data) && | ||||
183 | defined *$self->{FH}->flush() ; | ||||
184 | } | ||||
185 | else { | ||||
186 | my $buf = *$self->{Buffer} ; | ||||
187 | substr($$buf, *$self->{BufferOffset}, length $out_data) = $out_data ; | ||||
188 | *$self->{BufferOffset} += length($out_data) ; | ||||
189 | return 1; | ||||
190 | } | ||||
191 | } | ||||
192 | |||||
193 | sub smartReadExact | ||||
194 | # spent 2.91ms (441µs+2.47) within IO::Uncompress::Base::smartReadExact which was called 78 times, avg 37µs/call:
# 72 times (345µs+1.64ms) by IO::Uncompress::Gunzip::_readGzipHeader at line 193 of IO/Uncompress/Gunzip.pm, avg 28µs/call
# 3 times (58µs+748µs) by IO::Uncompress::Gunzip::ckMagic at line 69 of IO/Uncompress/Gunzip.pm, avg 269µs/call
# 3 times (38µs+81µs) by IO::Uncompress::Gunzip::_readGzipHeader at line 152 of IO/Uncompress/Gunzip.pm, avg 40µs/call | ||||
195 | 78 | 398µs | 78 | 2.47ms | return $_[0]->smartRead($_[1], $_[2]) == $_[2]; # spent 2.47ms making 78 calls to IO::Uncompress::Base::smartRead, avg 32µs/call |
196 | } | ||||
197 | |||||
198 | sub smartEof | ||||
199 | # spent 26.6ms (13.0+13.5) within IO::Uncompress::Base::smartEof which was called 645 times, avg 41µs/call:
# 631 times (12.9ms+13.3ms) by IO::Uncompress::Base::_raw_read at line 913, avg 42µs/call
# 12 times (119µs+180µs) by IO::Uncompress::Base::eof at line 1331, avg 25µs/call
# 2 times (24µs+30µs) by IO::Uncompress::Base::_raw_read at line 967, avg 27µs/call | ||||
200 | 645 | 260µs | my ($self) = $_[0]; | ||
201 | 645 | 886µs | local $.; | ||
202 | |||||
203 | 645 | 392µs | return 0 if length *$self->{Prime} || *$self->{PushMode}; | ||
204 | |||||
205 | 645 | 213µs | if (defined *$self->{FH}) | ||
206 | { | ||||
207 | # Could use | ||||
208 | # | ||||
209 | # *$self->{FH}->eof() | ||||
210 | # | ||||
211 | # here, but this can cause trouble if | ||||
212 | # the filehandle is itself a tied handle, but it uses sysread. | ||||
213 | # Then we get into mixing buffered & non-buffered IO, | ||||
214 | # which will cause trouble | ||||
215 | |||||
216 | 645 | 755µs | 645 | 1.43ms | my $info = $self->getErrInfo(); # spent 1.43ms making 645 calls to IO::Uncompress::Base::getErrInfo, avg 2µs/call |
217 | |||||
218 | 645 | 150µs | my $buffer = ''; | ||
219 | 645 | 846µs | 645 | 8.90ms | my $status = $self->smartRead(\$buffer, 1); # spent 8.90ms making 645 calls to IO::Uncompress::Base::smartRead, avg 14µs/call |
220 | 645 | 785µs | 591 | 1.82ms | $self->pushBack($buffer) if length $buffer; # spent 1.82ms making 591 calls to IO::Uncompress::Base::pushBack, avg 3µs/call |
221 | 645 | 713µs | 645 | 1.38ms | $self->setErrInfo($info); # spent 1.38ms making 645 calls to IO::Uncompress::Base::setErrInfo, avg 2µs/call |
222 | |||||
223 | 645 | 2.53ms | return $status == 0 ; | ||
224 | } | ||||
225 | elsif (defined *$self->{InputEvent}) | ||||
226 | { *$self->{EventEof} } | ||||
227 | else | ||||
228 | { *$self->{BufferOffset} >= length(${ *$self->{Buffer} }) } | ||||
229 | } | ||||
230 | |||||
231 | sub clearError | ||||
232 | { | ||||
233 | my $self = shift ; | ||||
234 | |||||
235 | *$self->{ErrorNo} = 0 ; | ||||
236 | ${ *$self->{Error} } = '' ; | ||||
237 | } | ||||
238 | |||||
239 | sub getErrInfo | ||||
240 | # spent 1.43ms within IO::Uncompress::Base::getErrInfo which was called 645 times, avg 2µs/call:
# 645 times (1.43ms+0s) by IO::Uncompress::Base::smartEof at line 216, avg 2µs/call | ||||
241 | 645 | 163µs | my $self = shift ; | ||
242 | |||||
243 | 645 | 5.63ms | return [ *$self->{ErrorNo}, ${ *$self->{Error} } ] ; | ||
244 | } | ||||
245 | |||||
246 | sub setErrInfo | ||||
247 | # spent 1.38ms within IO::Uncompress::Base::setErrInfo which was called 645 times, avg 2µs/call:
# 645 times (1.38ms+0s) by IO::Uncompress::Base::smartEof at line 221, avg 2µs/call | ||||
248 | 645 | 200µs | my $self = shift ; | ||
249 | 645 | 80µs | my $ref = shift; | ||
250 | |||||
251 | 645 | 288µs | *$self->{ErrorNo} = $ref->[0] ; | ||
252 | 645 | 1.39ms | ${ *$self->{Error} } = $ref->[1] ; | ||
253 | } | ||||
254 | |||||
255 | sub saveStatus | ||||
256 | # spent 4.94ms within IO::Uncompress::Base::saveStatus which was called 1991 times, avg 2µs/call:
# 1354 times (3.45ms+0s) by IO::Uncompress::Base::smartRead at line 108, avg 3µs/call
# 631 times (1.47ms+0s) by IO::Uncompress::Base::_raw_read at line 919, avg 2µs/call
# 3 times (14µs+0s) by IO::Uncompress::Base::close at line 1371, avg 5µs/call
# 3 times (6µs+0s) by IO::Uncompress::Base::_create at line 525, avg 2µs/call | ||||
257 | 1991 | 513µs | my $self = shift ; | ||
258 | 1991 | 399µs | my $errno = shift() + 0 ; | ||
259 | |||||
260 | 1991 | 654µs | *$self->{ErrorNo} = $errno; | ||
261 | 1991 | 1.03ms | ${ *$self->{Error} } = '' ; | ||
262 | |||||
263 | 1991 | 4.14ms | return *$self->{ErrorNo} ; | ||
264 | } | ||||
265 | |||||
266 | |||||
267 | sub saveErrorString | ||||
268 | { | ||||
269 | my $self = shift ; | ||||
270 | my $retval = shift ; | ||||
271 | |||||
272 | ${ *$self->{Error} } = shift ; | ||||
273 | *$self->{ErrorNo} = @_ ? shift() + 0 : STATUS_ERROR ; | ||||
274 | |||||
275 | return $retval; | ||||
276 | } | ||||
277 | |||||
278 | sub croakError | ||||
279 | { | ||||
280 | my $self = shift ; | ||||
281 | $self->saveErrorString(0, $_[0]); | ||||
282 | croak $_[0]; | ||||
283 | } | ||||
284 | |||||
285 | |||||
286 | sub closeError | ||||
287 | { | ||||
288 | my $self = shift ; | ||||
289 | my $retval = shift ; | ||||
290 | |||||
291 | my $errno = *$self->{ErrorNo}; | ||||
292 | my $error = ${ *$self->{Error} }; | ||||
293 | |||||
294 | $self->close(); | ||||
295 | |||||
296 | *$self->{ErrorNo} = $errno ; | ||||
297 | ${ *$self->{Error} } = $error ; | ||||
298 | |||||
299 | return $retval; | ||||
300 | } | ||||
301 | |||||
302 | sub error | ||||
303 | { | ||||
304 | my $self = shift ; | ||||
305 | return ${ *$self->{Error} } ; | ||||
306 | } | ||||
307 | |||||
308 | sub errorNo | ||||
309 | # spent 1.43ms within IO::Uncompress::Base::errorNo which was called 1271 times, avg 1µs/call:
# 1271 times (1.43ms+0s) by Compress::Zlib::_save_gzerr at line 96 of Compress/Zlib.pm, avg 1µs/call | ||||
310 | 1271 | 196µs | my $self = shift ; | ||
311 | 1271 | 2.54ms | return *$self->{ErrorNo}; | ||
312 | } | ||||
313 | |||||
314 | sub HeaderError | ||||
315 | { | ||||
316 | my ($self) = shift; | ||||
317 | return $self->saveErrorString(undef, "Header Error: $_[0]", STATUS_ERROR); | ||||
318 | } | ||||
319 | |||||
320 | sub TrailerError | ||||
321 | { | ||||
322 | my ($self) = shift; | ||||
323 | return $self->saveErrorString(G_ERR, "Trailer Error: $_[0]", STATUS_ERROR); | ||||
324 | } | ||||
325 | |||||
326 | sub TruncatedHeader | ||||
327 | { | ||||
328 | my ($self) = shift; | ||||
329 | return $self->HeaderError("Truncated in $_[0] Section"); | ||||
330 | } | ||||
331 | |||||
332 | sub TruncatedTrailer | ||||
333 | { | ||||
334 | my ($self) = shift; | ||||
335 | return $self->TrailerError("Truncated in $_[0] Section"); | ||||
336 | } | ||||
337 | |||||
338 | sub postCheckParams | ||||
339 | # spent 5µs within IO::Uncompress::Base::postCheckParams which was called 3 times, avg 2µs/call:
# 3 times (5µs+0s) by IO::Uncompress::Base::checkParams at line 377, avg 2µs/call | ||||
340 | 3 | 9µs | return 1; | ||
341 | } | ||||
342 | |||||
343 | sub checkParams | ||||
344 | # spent 898µs (258+640) within IO::Uncompress::Base::checkParams which was called 3 times, avg 299µs/call:
# 3 times (258µs+640µs) by IO::Uncompress::Base::_create at line 397, avg 299µs/call | ||||
345 | 3 | 13µs | my $self = shift ; | ||
346 | 3 | 1µs | my $class = shift ; | ||
347 | |||||
348 | 3 | 39µs | 3 | 52µs | my $got = shift || IO::Compress::Base::Parameters::new(); # spent 52µs making 3 calls to IO::Compress::Base::Parameters::new, avg 17µs/call |
349 | |||||
350 | 3 | 103µs | 3 | 8µs | my $Valid = { # spent 8µs making 3 calls to IO::Uncompress::Gunzip::getExtraParams, avg 3µs/call |
351 | 'blocksize' => [IO::Compress::Base::Common::Parse_unsigned, 16 * 1024], | ||||
352 | 'autoclose' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
353 | 'strict' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
354 | 'append' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
355 | 'prime' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
356 | 'multistream' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
357 | 'transparent' => [IO::Compress::Base::Common::Parse_any, 1], | ||||
358 | 'scan' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
359 | 'inputlength' => [IO::Compress::Base::Common::Parse_unsigned, undef], | ||||
360 | 'binmodeout' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
361 | #'decode' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
362 | |||||
363 | #'consumeinput' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
364 | |||||
365 | $self->getExtraParams(), | ||||
366 | |||||
367 | #'Todo - Revert to ordinary file on end Z_STREAM_END'=> 0, | ||||
368 | # ContinueAfterEof | ||||
369 | } ; | ||||
370 | |||||
371 | $Valid->{trailingdata} = [IO::Compress::Base::Common::Parse_writable_scalar, undef] | ||||
372 | 3 | 12µs | if *$self->{OneShot} ; | ||
373 | |||||
374 | 3 | 23µs | 3 | 575µs | $got->parse($Valid, @_ ) # spent 575µs making 3 calls to IO::Compress::Base::Parameters::parse, avg 192µs/call |
375 | or $self->croakError("${class}: " . $got->getError()) ; | ||||
376 | |||||
377 | 3 | 28µs | 3 | 5µs | $self->postCheckParams($got) # spent 5µs making 3 calls to IO::Uncompress::Base::postCheckParams, avg 2µs/call |
378 | or $self->croakError("${class}: " . $self->error()) ; | ||||
379 | |||||
380 | 3 | 23µs | return $got; | ||
381 | } | ||||
382 | |||||
383 | sub _create | ||||
384 | # spent 12.8ms (901µs+11.8) within IO::Uncompress::Base::_create which was called 3 times, avg 4.25ms/call:
# 3 times (901µs+11.8ms) by IO::Uncompress::Gunzip::new at line 39 of IO/Uncompress/Gunzip.pm, avg 4.25ms/call | ||||
385 | 3 | 1µs | my $obj = shift; | ||
386 | 3 | 0s | my $got = shift; | ||
387 | 3 | 3µs | my $append_mode = shift ; | ||
388 | |||||
389 | 3 | 11µs | my $class = ref $obj; | ||
390 | 3 | 1µs | $obj->croakError("$class: Missing Input parameter") | ||
391 | if ! @_ && ! $got ; | ||||
392 | |||||
393 | 3 | 3µs | my $inValue = shift ; | ||
394 | |||||
395 | 3 | 30µs | *$obj->{OneShot} = 0 ; | ||
396 | |||||
397 | 3 | 40µs | 3 | 898µs | if (! $got) # spent 898µs making 3 calls to IO::Uncompress::Base::checkParams, avg 299µs/call |
398 | { | ||||
399 | $got = $obj->checkParams($class, undef, @_) | ||||
400 | or return undef ; | ||||
401 | } | ||||
402 | |||||
403 | 3 | 72µs | 3 | 232µs | my $inType = whatIsInput($inValue, 1); # spent 232µs making 3 calls to IO::Compress::Base::Common::whatIsInput, avg 77µs/call |
404 | |||||
405 | 3 | 47µs | 3 | 143µs | $obj->ckInputParam($class, $inValue, 1) # spent 143µs making 3 calls to IO::Uncompress::Base::ckInputParam, avg 48µs/call |
406 | or return undef ; | ||||
407 | |||||
408 | 3 | 17µs | *$obj->{InNew} = 1; | ||
409 | |||||
410 | $obj->ckParams($got) | ||||
411 | 3 | 32µs | 3 | 62µs | or $obj->croakError("${class}: " . *$obj->{Error}); # spent 62µs making 3 calls to IO::Uncompress::Gunzip::ckParams, avg 21µs/call |
412 | |||||
413 | 3 | 16µs | if ($inType eq 'buffer' || $inType eq 'code') { | ||
414 | *$obj->{Buffer} = $inValue ; | ||||
415 | *$obj->{InputEvent} = $inValue | ||||
416 | if $inType eq 'code' ; | ||||
417 | } | ||||
418 | else { | ||||
419 | 3 | 3µs | if ($inType eq 'handle') { | ||
420 | *$obj->{FH} = $inValue ; | ||||
421 | *$obj->{Handle} = 1 ; | ||||
422 | |||||
423 | # Need to rewind for Scan | ||||
424 | *$obj->{FH}->seek(0, SEEK_SET) | ||||
425 | if $got->getValue('scan'); | ||||
426 | } | ||||
427 | else { | ||||
428 | 2 | 5.52ms | 2 | 77µs | # spent 52µs (27+25) within IO::Uncompress::Base::BEGIN@428 which was called:
# once (27µs+25µs) by IO::Uncompress::RawInflate::BEGIN@11 at line 428 # spent 52µs making 1 call to IO::Uncompress::Base::BEGIN@428
# spent 25µs making 1 call to warnings::unimport |
429 | 3 | 4µs | my $mode = '<'; | ||
430 | 3 | 7µs | 3 | 8µs | $mode = '+<' if $got->getValue('scan'); # spent 8µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 3µs/call |
431 | 3 | 10µs | *$obj->{StdIO} = ($inValue eq '-'); | ||
432 | 3 | 48µs | 3 | 296µs | *$obj->{FH} = new IO::File "$mode $inValue" # spent 296µs making 3 calls to IO::File::new, avg 99µs/call |
433 | or return $obj->saveErrorString(undef, "cannot open file '$inValue': $!", $!) ; | ||||
434 | } | ||||
435 | |||||
436 | 3 | 18µs | *$obj->{LineNo} = $. = 0; | ||
437 | 3 | 8µs | 3 | 36µs | setBinModeInput(*$obj->{FH}) ; # spent 36µs making 3 calls to IO::Compress::Base::Common::setBinModeInput, avg 12µs/call |
438 | |||||
439 | 3 | 3µs | my $buff = "" ; | ||
440 | 3 | 11µs | *$obj->{Buffer} = \$buff ; | ||
441 | } | ||||
442 | |||||
443 | # if ($got->getValue('decode')) { | ||||
444 | # my $want_encoding = $got->getValue('decode'); | ||||
445 | # *$obj->{Encoding} = IO::Compress::Base::Common::getEncoding($obj, $class, $want_encoding); | ||||
446 | # } | ||||
447 | # else { | ||||
448 | # *$obj->{Encoding} = undef; | ||||
449 | # } | ||||
450 | |||||
451 | 3 | 28µs | 3 | 7µs | *$obj->{InputLength} = $got->parsed('inputlength') # spent 7µs making 3 calls to IO::Compress::Base::Parameters::parsed, avg 2µs/call |
452 | ? $got->getValue('inputlength') | ||||
453 | : undef ; | ||||
454 | 3 | 23µs | 3 | 9µs | *$obj->{InputLengthRemaining} = $got->getValue('inputlength'); # spent 9µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 3µs/call |
455 | 3 | 3µs | *$obj->{BufferOffset} = 0 ; | ||
456 | 3 | 18µs | 3 | 4µs | *$obj->{AutoClose} = $got->getValue('autoclose'); # spent 4µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 1µs/call |
457 | 3 | 8µs | 3 | 2µs | *$obj->{Strict} = $got->getValue('strict'); # spent 2µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 667ns/call |
458 | 3 | 4µs | 3 | 3µs | *$obj->{BlockSize} = $got->getValue('blocksize'); # spent 3µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 1µs/call |
459 | 3 | 21µs | 3 | 4µs | *$obj->{Append} = $got->getValue('append'); # spent 4µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 1µs/call |
460 | 3 | 6µs | 3 | 5µs | *$obj->{AppendOutput} = $append_mode || $got->getValue('append'); # spent 5µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 2µs/call |
461 | 3 | 19µs | 3 | 6µs | *$obj->{ConsumeInput} = $got->getValue('consumeinput'); # spent 6µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 2µs/call |
462 | 3 | 7µs | 3 | 5µs | *$obj->{Transparent} = $got->getValue('transparent'); # spent 5µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 2µs/call |
463 | 3 | 6µs | 3 | 3µs | *$obj->{MultiStream} = $got->getValue('multistream'); # spent 3µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 1µs/call |
464 | |||||
465 | # TODO - move these two into RawDeflate | ||||
466 | 3 | 6µs | 3 | 5µs | *$obj->{Scan} = $got->getValue('scan'); # spent 5µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 2µs/call |
467 | 3 | 26µs | 6 | 12µs | *$obj->{ParseExtra} = $got->getValue('parseextra') # spent 12µs making 6 calls to IO::Compress::Base::Parameters::getValue, avg 2µs/call |
468 | || $got->getValue('strict') ; | ||||
469 | 3 | 6µs | *$obj->{Type} = ''; | ||
470 | 3 | 7µs | 3 | 8µs | *$obj->{Prime} = $got->getValue('prime') || '' ; # spent 8µs making 3 calls to IO::Compress::Base::Parameters::getValue, avg 3µs/call |
471 | 3 | 3µs | *$obj->{Pending} = ''; | ||
472 | 3 | 1µs | *$obj->{Plain} = 0; | ||
473 | 3 | 1µs | *$obj->{PlainBytesRead} = 0; | ||
474 | 3 | 12µs | *$obj->{InflatedBytesRead} = 0; | ||
475 | 3 | 52µs | 3 | 21µs | *$obj->{UnCompSize} = new U64; # spent 21µs making 3 calls to U64::new, avg 7µs/call |
476 | 3 | 7µs | 3 | 5µs | *$obj->{CompSize} = new U64; # spent 5µs making 3 calls to U64::new, avg 2µs/call |
477 | 3 | 4µs | *$obj->{TotalInflatedBytesRead} = 0; | ||
478 | 3 | 8µs | *$obj->{NewStream} = 0 ; | ||
479 | 3 | 15µs | *$obj->{EventEof} = 0 ; | ||
480 | 3 | 2µs | *$obj->{ClassName} = $class ; | ||
481 | 3 | 13µs | *$obj->{Params} = $got ; | ||
482 | |||||
483 | 3 | 1µs | if (*$obj->{ConsumeInput}) { | ||
484 | *$obj->{InNew} = 0; | ||||
485 | *$obj->{Closed} = 0; | ||||
486 | return $obj | ||||
487 | } | ||||
488 | |||||
489 | 3 | 73µs | 3 | 7.10ms | my $status = $obj->mkUncomp($got); # spent 7.10ms making 3 calls to IO::Uncompress::RawInflate::mkUncomp, avg 2.37ms/call |
490 | |||||
491 | return undef | ||||
492 | 3 | 1µs | unless defined $status; | ||
493 | |||||
494 | 3 | 2µs | *$obj->{InNew} = 0; | ||
495 | 3 | 16µs | *$obj->{Closed} = 0; | ||
496 | |||||
497 | 3 | 15µs | if ($status) { | ||
498 | # Need to try uncompressing to catch the case | ||||
499 | # where the compressed file uncompresses to an | ||||
500 | # empty string - so eof is set immediately. | ||||
501 | |||||
502 | 3 | 12µs | my $out_buffer = ''; | ||
503 | |||||
504 | 3 | 63µs | 3 | 2.93ms | $status = $obj->read(\$out_buffer); # spent 2.93ms making 3 calls to IO::Uncompress::Base::read, avg 977µs/call |
505 | |||||
506 | 3 | 7µs | if ($status < 0) { | ||
507 | *$obj->{ReadStatus} = [ $status, $obj->error(), $obj->errorNo() ]; | ||||
508 | } | ||||
509 | |||||
510 | 3 | 18µs | 3 | 40µs | $obj->ungetc($out_buffer) # spent 40µs making 3 calls to IO::Uncompress::Base::ungetc, avg 13µs/call |
511 | if length $out_buffer; | ||||
512 | } | ||||
513 | else { | ||||
514 | return undef | ||||
515 | unless *$obj->{Transparent}; | ||||
516 | |||||
517 | $obj->clearError(); | ||||
518 | *$obj->{Type} = 'plain'; | ||||
519 | *$obj->{Plain} = 1; | ||||
520 | $obj->pushBack(*$obj->{HeaderPending}) ; | ||||
521 | } | ||||
522 | |||||
523 | 3 | 13µs | push @{ *$obj->{InfoList} }, *$obj->{Info} ; | ||
524 | |||||
525 | 3 | 5µs | 3 | 6µs | $obj->saveStatus(STATUS_OK) ; # spent 6µs making 3 calls to IO::Uncompress::Base::saveStatus, avg 2µs/call |
526 | 3 | 2µs | *$obj->{InNew} = 0; | ||
527 | 3 | 2µs | *$obj->{Closed} = 0; | ||
528 | |||||
529 | 3 | 19µs | return $obj; | ||
530 | } | ||||
531 | |||||
532 | sub ckInputParam | ||||
533 | # spent 143µs (73+70) within IO::Uncompress::Base::ckInputParam which was called 3 times, avg 48µs/call:
# 3 times (73µs+70µs) by IO::Uncompress::Base::_create at line 405, avg 48µs/call | ||||
534 | 3 | 2µs | my $self = shift ; | ||
535 | 3 | 1µs | my $from = shift ; | ||
536 | 3 | 34µs | 3 | 70µs | my $inType = whatIsInput($_[0], $_[1]); # spent 70µs making 3 calls to IO::Compress::Base::Common::whatIsInput, avg 23µs/call |
537 | |||||
538 | 3 | 3µs | $self->croakError("$from: input parameter not a filename, filehandle, array ref or scalar ref") | ||
539 | if ! $inType ; | ||||
540 | |||||
541 | # if ($inType eq 'filename' ) | ||||
542 | # { | ||||
543 | # return $self->saveErrorString(1, "$from: input filename is undef or null string", STATUS_ERROR) | ||||
544 | # if ! defined $_[0] || $_[0] eq '' ; | ||||
545 | # | ||||
546 | # if ($_[0] ne '-' && ! -e $_[0] ) | ||||
547 | # { | ||||
548 | # return $self->saveErrorString(1, | ||||
549 | # "input file '$_[0]' does not exist", STATUS_ERROR); | ||||
550 | # } | ||||
551 | # } | ||||
552 | |||||
553 | 3 | 22µs | return 1; | ||
554 | } | ||||
555 | |||||
556 | |||||
557 | sub _inf | ||||
558 | { | ||||
559 | my $obj = shift ; | ||||
560 | |||||
561 | my $class = (caller)[0] ; | ||||
562 | my $name = (caller(1))[3] ; | ||||
563 | |||||
564 | $obj->croakError("$name: expected at least 1 parameters\n") | ||||
565 | unless @_ >= 1 ; | ||||
566 | |||||
567 | my $input = shift ; | ||||
568 | my $haveOut = @_ ; | ||||
569 | my $output = shift ; | ||||
570 | |||||
571 | |||||
572 | my $x = new IO::Compress::Base::Validator($class, *$obj->{Error}, $name, $input, $output) | ||||
573 | or return undef ; | ||||
574 | |||||
575 | push @_, $output if $haveOut && $x->{Hash}; | ||||
576 | |||||
577 | *$obj->{OneShot} = 1 ; | ||||
578 | |||||
579 | my $got = $obj->checkParams($name, undef, @_) | ||||
580 | or return undef ; | ||||
581 | |||||
582 | if ($got->parsed('trailingdata')) | ||||
583 | { | ||||
584 | # my $value = $got->valueRef('TrailingData'); | ||||
585 | # warn "TD $value "; | ||||
586 | # #$value = $$value; | ||||
587 | ## warn "TD $value $$value "; | ||||
588 | # | ||||
589 | # return retErr($obj, "Parameter 'TrailingData' not writable") | ||||
590 | # if readonly $$value ; | ||||
591 | # | ||||
592 | # if (ref $$value) | ||||
593 | # { | ||||
594 | # return retErr($obj,"Parameter 'TrailingData' not a scalar reference") | ||||
595 | # if ref $$value ne 'SCALAR' ; | ||||
596 | # | ||||
597 | # *$obj->{TrailingData} = $$value ; | ||||
598 | # } | ||||
599 | # else | ||||
600 | # { | ||||
601 | # return retErr($obj,"Parameter 'TrailingData' not a scalar") | ||||
602 | # if ref $value ne 'SCALAR' ; | ||||
603 | # | ||||
604 | # *$obj->{TrailingData} = $value ; | ||||
605 | # } | ||||
606 | |||||
607 | *$obj->{TrailingData} = $got->getValue('trailingdata'); | ||||
608 | } | ||||
609 | |||||
610 | *$obj->{MultiStream} = $got->getValue('multistream'); | ||||
611 | $got->setValue('multistream', 0); | ||||
612 | |||||
613 | $x->{Got} = $got ; | ||||
614 | |||||
615 | # if ($x->{Hash}) | ||||
616 | # { | ||||
617 | # while (my($k, $v) = each %$input) | ||||
618 | # { | ||||
619 | # $v = \$input->{$k} | ||||
620 | # unless defined $v ; | ||||
621 | # | ||||
622 | # $obj->_singleTarget($x, $k, $v, @_) | ||||
623 | # or return undef ; | ||||
624 | # } | ||||
625 | # | ||||
626 | # return keys %$input ; | ||||
627 | # } | ||||
628 | |||||
629 | if ($x->{GlobMap}) | ||||
630 | { | ||||
631 | $x->{oneInput} = 1 ; | ||||
632 | foreach my $pair (@{ $x->{Pairs} }) | ||||
633 | { | ||||
634 | my ($from, $to) = @$pair ; | ||||
635 | $obj->_singleTarget($x, $from, $to, @_) | ||||
636 | or return undef ; | ||||
637 | } | ||||
638 | |||||
639 | return scalar @{ $x->{Pairs} } ; | ||||
640 | } | ||||
641 | |||||
642 | if (! $x->{oneOutput} ) | ||||
643 | { | ||||
644 | my $inFile = ($x->{inType} eq 'filenames' | ||||
645 | || $x->{inType} eq 'filename'); | ||||
646 | |||||
647 | $x->{inType} = $inFile ? 'filename' : 'buffer'; | ||||
648 | |||||
649 | foreach my $in ($x->{oneInput} ? $input : @$input) | ||||
650 | { | ||||
651 | my $out ; | ||||
652 | $x->{oneInput} = 1 ; | ||||
653 | |||||
654 | $obj->_singleTarget($x, $in, $output, @_) | ||||
655 | or return undef ; | ||||
656 | } | ||||
657 | |||||
658 | return 1 ; | ||||
659 | } | ||||
660 | |||||
661 | # finally the 1 to 1 and n to 1 | ||||
662 | return $obj->_singleTarget($x, $input, $output, @_); | ||||
663 | |||||
664 | croak "should not be here" ; | ||||
665 | } | ||||
666 | |||||
667 | sub retErr | ||||
668 | { | ||||
669 | my $x = shift ; | ||||
670 | my $string = shift ; | ||||
671 | |||||
672 | ${ $x->{Error} } = $string ; | ||||
673 | |||||
674 | return undef ; | ||||
675 | } | ||||
676 | |||||
677 | sub _singleTarget | ||||
678 | { | ||||
679 | my $self = shift ; | ||||
680 | my $x = shift ; | ||||
681 | my $input = shift; | ||||
682 | my $output = shift; | ||||
683 | |||||
684 | my $buff = ''; | ||||
685 | $x->{buff} = \$buff ; | ||||
686 | |||||
687 | my $fh ; | ||||
688 | if ($x->{outType} eq 'filename') { | ||||
689 | my $mode = '>' ; | ||||
690 | $mode = '>>' | ||||
691 | if $x->{Got}->getValue('append') ; | ||||
692 | $x->{fh} = new IO::File "$mode $output" | ||||
693 | or return retErr($x, "cannot open file '$output': $!") ; | ||||
694 | binmode $x->{fh} if $x->{Got}->valueOrDefault('binmodeout'); | ||||
695 | |||||
696 | } | ||||
697 | |||||
698 | elsif ($x->{outType} eq 'handle') { | ||||
699 | $x->{fh} = $output; | ||||
700 | binmode $x->{fh} if $x->{Got}->valueOrDefault('binmodeout'); | ||||
701 | if ($x->{Got}->getValue('append')) { | ||||
702 | seek($x->{fh}, 0, SEEK_END) | ||||
703 | or return retErr($x, "Cannot seek to end of output filehandle: $!") ; | ||||
704 | } | ||||
705 | } | ||||
706 | |||||
707 | |||||
708 | elsif ($x->{outType} eq 'buffer' ) | ||||
709 | { | ||||
710 | $$output = '' | ||||
711 | unless $x->{Got}->getValue('append'); | ||||
712 | $x->{buff} = $output ; | ||||
713 | } | ||||
714 | |||||
715 | if ($x->{oneInput}) | ||||
716 | { | ||||
717 | defined $self->_rd2($x, $input, $output) | ||||
718 | or return undef; | ||||
719 | } | ||||
720 | else | ||||
721 | { | ||||
722 | for my $element ( ($x->{inType} eq 'hash') ? keys %$input : @$input) | ||||
723 | { | ||||
724 | defined $self->_rd2($x, $element, $output) | ||||
725 | or return undef ; | ||||
726 | } | ||||
727 | } | ||||
728 | |||||
729 | |||||
730 | if ( ($x->{outType} eq 'filename' && $output ne '-') || | ||||
731 | ($x->{outType} eq 'handle' && $x->{Got}->getValue('autoclose'))) { | ||||
732 | $x->{fh}->close() | ||||
733 | or return retErr($x, $!); | ||||
734 | delete $x->{fh}; | ||||
735 | } | ||||
736 | |||||
737 | return 1 ; | ||||
738 | } | ||||
739 | |||||
740 | sub _rd2 | ||||
741 | { | ||||
742 | my $self = shift ; | ||||
743 | my $x = shift ; | ||||
744 | my $input = shift; | ||||
745 | my $output = shift; | ||||
746 | |||||
747 | my $z = IO::Compress::Base::Common::createSelfTiedObject($x->{Class}, *$self->{Error}); | ||||
748 | |||||
749 | $z->_create($x->{Got}, 1, $input, @_) | ||||
750 | or return undef ; | ||||
751 | |||||
752 | my $status ; | ||||
753 | my $fh = $x->{fh}; | ||||
754 | |||||
755 | while (1) { | ||||
756 | |||||
757 | while (($status = $z->read($x->{buff})) > 0) { | ||||
758 | if ($fh) { | ||||
759 | local $\; | ||||
760 | print $fh ${ $x->{buff} } | ||||
761 | or return $z->saveErrorString(undef, "Error writing to output file: $!", $!); | ||||
762 | ${ $x->{buff} } = '' ; | ||||
763 | } | ||||
764 | } | ||||
765 | |||||
766 | if (! $x->{oneOutput} ) { | ||||
767 | my $ot = $x->{outType} ; | ||||
768 | |||||
769 | if ($ot eq 'array') | ||||
770 | { push @$output, $x->{buff} } | ||||
771 | elsif ($ot eq 'hash') | ||||
772 | { $output->{$input} = $x->{buff} } | ||||
773 | |||||
774 | my $buff = ''; | ||||
775 | $x->{buff} = \$buff; | ||||
776 | } | ||||
777 | |||||
778 | last if $status < 0 || $z->smartEof(); | ||||
779 | |||||
780 | last | ||||
781 | unless *$self->{MultiStream}; | ||||
782 | |||||
783 | $status = $z->nextStream(); | ||||
784 | |||||
785 | last | ||||
786 | unless $status == 1 ; | ||||
787 | } | ||||
788 | |||||
789 | return $z->closeError(undef) | ||||
790 | if $status < 0 ; | ||||
791 | |||||
792 | ${ *$self->{TrailingData} } = $z->trailingData() | ||||
793 | if defined *$self->{TrailingData} ; | ||||
794 | |||||
795 | $z->close() | ||||
796 | or return undef ; | ||||
797 | |||||
798 | return 1 ; | ||||
799 | } | ||||
800 | |||||
801 | sub TIEHANDLE | ||||
802 | # spent 91µs within IO::Uncompress::Base::TIEHANDLE which was called 3 times, avg 30µs/call:
# 3 times (91µs+0s) by IO::Compress::Base::Common::createSelfTiedObject at line 450 of IO/Compress/Base/Common.pm, avg 30µs/call | ||||
803 | 3 | 60µs | return $_[0] if ref($_[0]); | ||
804 | die "OOPS\n" ; | ||||
805 | |||||
806 | } | ||||
807 | |||||
808 | sub UNTIE | ||||
809 | # spent 5µs within IO::Uncompress::Base::UNTIE which was called 3 times, avg 2µs/call:
# 3 times (5µs+0s) by IO::Uncompress::Base::close at line 1360, avg 2µs/call | ||||
810 | 3 | 14µs | my $self = shift ; | ||
811 | } | ||||
812 | |||||
813 | |||||
814 | sub getHeaderInfo | ||||
815 | { | ||||
816 | my $self = shift ; | ||||
817 | wantarray ? @{ *$self->{InfoList} } : *$self->{Info}; | ||||
818 | } | ||||
819 | |||||
820 | sub readBlock | ||||
821 | # spent 18.2ms (2.58+15.6) within IO::Uncompress::Base::readBlock which was called 631 times, avg 29µs/call:
# 631 times (2.58ms+15.6ms) by IO::Uncompress::Base::_raw_read at line 902, avg 29µs/call | ||||
822 | 631 | 104µs | my $self = shift ; | ||
823 | 631 | 86µs | my $buff = shift ; | ||
824 | 631 | 94µs | my $size = shift ; | ||
825 | |||||
826 | 631 | 188µs | if (defined *$self->{CompressedInputLength}) { | ||
827 | if (*$self->{CompressedInputLengthRemaining} == 0) { | ||||
828 | delete *$self->{CompressedInputLength}; | ||||
829 | *$self->{CompressedInputLengthDone} = 1; | ||||
830 | return STATUS_OK ; | ||||
831 | } | ||||
832 | $size = List::Util::min($size, *$self->{CompressedInputLengthRemaining} ); | ||||
833 | *$self->{CompressedInputLengthRemaining} -= $size ; | ||||
834 | } | ||||
835 | |||||
836 | 631 | 716µs | 631 | 15.6ms | my $status = $self->smartRead($buff, $size) ; # spent 15.6ms making 631 calls to IO::Uncompress::Base::smartRead, avg 25µs/call |
837 | 631 | 169µs | return $self->saveErrorString(STATUS_ERROR, "Error Reading Data: $!", $!) | ||
838 | if $status == STATUS_ERROR ; | ||||
839 | |||||
840 | 631 | 69µs | if ($status == 0 ) { | ||
841 | *$self->{Closed} = 1 ; | ||||
842 | *$self->{EndStream} = 1 ; | ||||
843 | return $self->saveErrorString(STATUS_ERROR, "unexpected end of file", STATUS_ERROR); | ||||
844 | } | ||||
845 | |||||
846 | 631 | 1.11ms | return STATUS_OK; | ||
847 | } | ||||
848 | |||||
849 | sub postBlockChk | ||||
850 | # spent 531µs within IO::Uncompress::Base::postBlockChk which was called 631 times, avg 842ns/call:
# 631 times (531µs+0s) by IO::Uncompress::Base::_raw_read at line 921, avg 842ns/call | ||||
851 | 631 | 1.04ms | return STATUS_OK; | ||
852 | } | ||||
853 | |||||
854 | sub _raw_read | ||||
855 | { | ||||
856 | # return codes | ||||
857 | # >0 - ok, number of bytes read | ||||
858 | # =0 - ok, eof | ||||
859 | # <0 - not ok | ||||
860 | |||||
861 | 631 | 156µs | my $self = shift ; | ||
862 | |||||
863 | 631 | 190µs | return G_EOF if *$self->{Closed} ; | ||
864 | 631 | 126µs | return G_EOF if *$self->{EndStream} ; | ||
865 | |||||
866 | 631 | 88µs | my $buffer = shift ; | ||
867 | 631 | 86µs | my $scan_mode = shift ; | ||
868 | |||||
869 | 631 | 167µs | if (*$self->{Plain}) { | ||
870 | my $tmp_buff ; | ||||
871 | my $len = $self->smartRead(\$tmp_buff, *$self->{BlockSize}) ; | ||||
872 | |||||
873 | return $self->saveErrorString(G_ERR, "Error reading data: $!", $!) | ||||
874 | if $len == STATUS_ERROR ; | ||||
875 | |||||
876 | if ($len == 0 ) { | ||||
877 | *$self->{EndStream} = 1 ; | ||||
878 | } | ||||
879 | else { | ||||
880 | *$self->{PlainBytesRead} += $len ; | ||||
881 | $$buffer .= $tmp_buff; | ||||
882 | } | ||||
883 | |||||
884 | return $len ; | ||||
885 | } | ||||
886 | |||||
887 | 631 | 118µs | if (*$self->{NewStream}) { | ||
888 | |||||
889 | $self->gotoNextStream() > 0 | ||||
890 | or return G_ERR; | ||||
891 | |||||
892 | # For the headers that actually uncompressed data, put the | ||||
893 | # uncompressed data into the output buffer. | ||||
894 | $$buffer .= *$self->{Pending} ; | ||||
895 | my $len = length *$self->{Pending} ; | ||||
896 | *$self->{Pending} = ''; | ||||
897 | return $len; | ||||
898 | } | ||||
899 | |||||
900 | 631 | 134µs | my $temp_buf = ''; | ||
901 | 631 | 88µs | my $outSize = 0; | ||
902 | 631 | 798µs | 631 | 18.2ms | my $status = $self->readBlock(\$temp_buf, *$self->{BlockSize}, $outSize) ; # spent 18.2ms making 631 calls to IO::Uncompress::Base::readBlock, avg 29µs/call |
903 | |||||
904 | 631 | 76µs | return G_ERR | ||
905 | if $status == STATUS_ERROR ; | ||||
906 | |||||
907 | 631 | 111µs | my $buf_len = 0; | ||
908 | 631 | 185µs | if ($status == STATUS_OK) { | ||
909 | 631 | 124µs | my $beforeC_len = length $temp_buf; | ||
910 | 631 | 234µs | my $before_len = defined $$buffer ? length $$buffer : 0 ; | ||
911 | $status = *$self->{Uncomp}->uncompr(\$temp_buf, $buffer, | ||||
912 | defined *$self->{CompressedInputLengthDone} || | ||||
913 | 631 | 2.26ms | 1262 | 69.6ms | $self->smartEof(), $outSize); # spent 43.4ms making 631 calls to IO::Uncompress::Adapter::Inflate::uncompr, avg 69µs/call
# spent 26.2ms making 631 calls to IO::Uncompress::Base::smartEof, avg 42µs/call |
914 | |||||
915 | # Remember the input buffer if it wasn't consumed completely | ||||
916 | 631 | 1.03ms | 631 | 3.72ms | $self->pushBack($temp_buf) if *$self->{Uncomp}{ConsumesInput}; # spent 3.72ms making 631 calls to IO::Uncompress::Base::pushBack, avg 6µs/call |
917 | |||||
918 | return $self->saveErrorString(G_ERR, *$self->{Uncomp}{Error}, *$self->{Uncomp}{ErrorNo}) | ||||
919 | 631 | 779µs | 631 | 1.47ms | if $self->saveStatus($status) == STATUS_ERROR; # spent 1.47ms making 631 calls to IO::Uncompress::Base::saveStatus, avg 2µs/call |
920 | |||||
921 | 631 | 778µs | 631 | 531µs | $self->postBlockChk($buffer, $before_len) == STATUS_OK # spent 531µs making 631 calls to IO::Uncompress::Base::postBlockChk, avg 842ns/call |
922 | or return G_ERR; | ||||
923 | |||||
924 | 631 | 362µs | $buf_len = defined $$buffer ? length($$buffer) - $before_len : 0; | ||
925 | |||||
926 | 631 | 990µs | 631 | 1.64ms | *$self->{CompSize}->add($beforeC_len - length $temp_buf) ; # spent 1.64ms making 631 calls to U64::add, avg 3µs/call |
927 | |||||
928 | 631 | 225µs | *$self->{InflatedBytesRead} += $buf_len ; | ||
929 | 631 | 133µs | *$self->{TotalInflatedBytesRead} += $buf_len ; | ||
930 | 631 | 763µs | 631 | 1.13ms | *$self->{UnCompSize}->add($buf_len) ; # spent 1.13ms making 631 calls to U64::add, avg 2µs/call |
931 | |||||
932 | 631 | 1.01ms | 631 | 577µs | $self->filterUncompressed($buffer, $before_len); # spent 577µs making 631 calls to IO::Uncompress::Base::filterUncompressed, avg 914ns/call |
933 | |||||
934 | # if (*$self->{Encoding}) { | ||||
935 | # use Encode ; | ||||
936 | # *$self->{PendingDecode} .= substr($$buffer, $before_len) ; | ||||
937 | # my $got = *$self->{Encoding}->decode(*$self->{PendingDecode}, Encode::FB_QUIET) ; | ||||
938 | # substr($$buffer, $before_len) = $got; | ||||
939 | # } | ||||
940 | } | ||||
941 | |||||
942 | 631 | 132µs | if ($status == STATUS_ENDSTREAM) { | ||
943 | |||||
944 | 2 | 6µs | *$self->{EndStream} = 1 ; | ||
945 | |||||
946 | 2 | 0s | my $trailer; | ||
947 | 2 | 0s | my $trailer_size = *$self->{Info}{TrailerLength} ; | ||
948 | 2 | 0s | my $got = 0; | ||
949 | 2 | 5µs | 2 | 8µs | if (*$self->{Info}{TrailerLength}) # spent 8µs making 2 calls to IO::Uncompress::Base::smartRead, avg 4µs/call |
950 | { | ||||
951 | $got = $self->smartRead(\$trailer, $trailer_size) ; | ||||
952 | } | ||||
953 | |||||
954 | 2 | 7µs | 2 | 39µs | if ($got == $trailer_size) { # spent 39µs making 2 calls to IO::Uncompress::Gunzip::chkTrailer, avg 20µs/call |
955 | $self->chkTrailer($trailer) == STATUS_OK | ||||
956 | or return G_ERR; | ||||
957 | } | ||||
958 | else { | ||||
959 | return $self->TrailerError("trailer truncated. Expected " . | ||||
960 | "$trailer_size bytes, got $got") | ||||
961 | if *$self->{Strict}; | ||||
962 | $self->pushBack($trailer) ; | ||||
963 | } | ||||
964 | |||||
965 | # TODO - if want file pointer, do it here | ||||
966 | |||||
967 | 2 | 5µs | 2 | 54µs | if (! $self->smartEof()) { # spent 54µs making 2 calls to IO::Uncompress::Base::smartEof, avg 27µs/call |
968 | *$self->{NewStream} = 1 ; | ||||
969 | |||||
970 | if (*$self->{MultiStream}) { | ||||
971 | *$self->{EndStream} = 0 ; | ||||
972 | return $buf_len ; | ||||
973 | } | ||||
974 | } | ||||
975 | |||||
976 | } | ||||
977 | |||||
978 | |||||
979 | # return the number of uncompressed bytes read | ||||
980 | 631 | 1.19ms | return $buf_len ; | ||
981 | } | ||||
982 | |||||
983 | sub reset | ||||
984 | { | ||||
985 | my $self = shift ; | ||||
986 | |||||
987 | return *$self->{Uncomp}->reset(); | ||||
988 | } | ||||
989 | |||||
990 | sub filterUncompressed | ||||
991 | 631 | 1.08ms | # spent 577µs within IO::Uncompress::Base::filterUncompressed which was called 631 times, avg 914ns/call:
# 631 times (577µs+0s) by IO::Uncompress::Base::_raw_read at line 932, avg 914ns/call | ||
992 | } | ||||
993 | |||||
994 | #sub isEndStream | ||||
995 | #{ | ||||
996 | # my $self = shift ; | ||||
997 | # return *$self->{NewStream} || | ||||
998 | # *$self->{EndStream} ; | ||||
999 | #} | ||||
1000 | |||||
1001 | sub nextStream | ||||
1002 | { | ||||
1003 | my $self = shift ; | ||||
1004 | |||||
1005 | my $status = $self->gotoNextStream(); | ||||
1006 | $status == 1 | ||||
1007 | or return $status ; | ||||
1008 | |||||
1009 | *$self->{TotalInflatedBytesRead} = 0 ; | ||||
1010 | *$self->{LineNo} = $. = 0; | ||||
1011 | |||||
1012 | return 1; | ||||
1013 | } | ||||
1014 | |||||
1015 | sub gotoNextStream | ||||
1016 | { | ||||
1017 | my $self = shift ; | ||||
1018 | |||||
1019 | if (! *$self->{NewStream}) { | ||||
1020 | my $status = 1; | ||||
1021 | my $buffer ; | ||||
1022 | |||||
1023 | # TODO - make this more efficient if know the offset for the end of | ||||
1024 | # the stream and seekable | ||||
1025 | $status = $self->read($buffer) | ||||
1026 | while $status > 0 ; | ||||
1027 | |||||
1028 | return $status | ||||
1029 | if $status < 0; | ||||
1030 | } | ||||
1031 | |||||
1032 | *$self->{NewStream} = 0 ; | ||||
1033 | *$self->{EndStream} = 0 ; | ||||
1034 | *$self->{CompressedInputLengthDone} = undef ; | ||||
1035 | *$self->{CompressedInputLength} = undef ; | ||||
1036 | $self->reset(); | ||||
1037 | *$self->{UnCompSize}->reset(); | ||||
1038 | *$self->{CompSize}->reset(); | ||||
1039 | |||||
1040 | my $magic = $self->ckMagic(); | ||||
1041 | |||||
1042 | if ( ! defined $magic) { | ||||
1043 | if (! *$self->{Transparent} || $self->eof()) | ||||
1044 | { | ||||
1045 | *$self->{EndStream} = 1 ; | ||||
1046 | return 0; | ||||
1047 | } | ||||
1048 | |||||
1049 | $self->clearError(); | ||||
1050 | *$self->{Type} = 'plain'; | ||||
1051 | *$self->{Plain} = 1; | ||||
1052 | $self->pushBack(*$self->{HeaderPending}) ; | ||||
1053 | } | ||||
1054 | else | ||||
1055 | { | ||||
1056 | *$self->{Info} = $self->readHeader($magic); | ||||
1057 | |||||
1058 | if ( ! defined *$self->{Info} ) { | ||||
1059 | *$self->{EndStream} = 1 ; | ||||
1060 | return -1; | ||||
1061 | } | ||||
1062 | } | ||||
1063 | |||||
1064 | push @{ *$self->{InfoList} }, *$self->{Info} ; | ||||
1065 | |||||
1066 | return 1; | ||||
1067 | } | ||||
1068 | |||||
1069 | sub streamCount | ||||
1070 | { | ||||
1071 | my $self = shift ; | ||||
1072 | return 1 if ! defined *$self->{InfoList}; | ||||
1073 | return scalar @{ *$self->{InfoList} } ; | ||||
1074 | } | ||||
1075 | |||||
1076 | #sub read | ||||
1077 | #{ | ||||
1078 | # my $status = myRead(@_); | ||||
1079 | # return undef if $status < 0; | ||||
1080 | # return $status; | ||||
1081 | #} | ||||
1082 | |||||
1083 | sub read | ||||
1084 | # spent 125ms (10.5+114) within IO::Uncompress::Base::read which was called 635 times, avg 197µs/call:
# 632 times (10.3ms+112ms) by Compress::Zlib::gzFile::gzread at line 174 of Compress/Zlib.pm, avg 193µs/call
# 3 times (225µs+2.71ms) by IO::Uncompress::Base::_create at line 504, avg 977µs/call | ||||
1085 | # return codes | ||||
1086 | # >0 - ok, number of bytes read | ||||
1087 | # =0 - ok, eof | ||||
1088 | # <0 - not ok | ||||
1089 | |||||
1090 | 635 | 150µs | my $self = shift ; | ||
1091 | |||||
1092 | 635 | 298µs | if (defined *$self->{ReadStatus} ) { | ||
1093 | my $status = *$self->{ReadStatus}[0]; | ||||
1094 | $self->saveErrorString( @{ *$self->{ReadStatus} } ); | ||||
1095 | delete *$self->{ReadStatus} ; | ||||
1096 | return $status ; | ||||
1097 | } | ||||
1098 | |||||
1099 | 635 | 167µs | return G_EOF if *$self->{Closed} ; | ||
1100 | |||||
1101 | 635 | 85µs | my $buffer ; | ||
1102 | |||||
1103 | 635 | 262µs | if (ref $_[0] ) { | ||
1104 | $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only") | ||||
1105 | 3 | 37µs | 3 | 17µs | if Scalar::Util::readonly(${ $_[0] }); # spent 17µs making 3 calls to Scalar::Util::readonly, avg 6µs/call |
1106 | |||||
1107 | 3 | 3µs | $self->croakError(*$self->{ClassName} . "::read: not a scalar reference $_[0]" ) | ||
1108 | unless ref $_[0] eq 'SCALAR' ; | ||||
1109 | 3 | 1µs | $buffer = $_[0] ; | ||
1110 | } | ||||
1111 | else { | ||||
1112 | 632 | 1.72ms | 632 | 532µs | $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only") # spent 532µs making 632 calls to Scalar::Util::readonly, avg 842ns/call |
1113 | if Scalar::Util::readonly($_[0]); | ||||
1114 | |||||
1115 | 632 | 273µs | $buffer = \$_[0] ; | ||
1116 | } | ||||
1117 | |||||
1118 | 635 | 119µs | my $length = $_[1] ; | ||
1119 | 635 | 139µs | my $offset = $_[2] || 0; | ||
1120 | |||||
1121 | 635 | 294µs | if (! *$self->{AppendOutput}) { | ||
1122 | 635 | 158µs | if (! $offset) { | ||
1123 | 635 | 277µs | $$buffer = '' ; | ||
1124 | } | ||||
1125 | else { | ||||
1126 | if ($offset > length($$buffer)) { | ||||
1127 | $$buffer .= "\x00" x ($offset - length($$buffer)); | ||||
1128 | } | ||||
1129 | else { | ||||
1130 | substr($$buffer, $offset) = ''; | ||||
1131 | } | ||||
1132 | } | ||||
1133 | } | ||||
1134 | elsif (! defined $$buffer) { | ||||
1135 | $$buffer = '' ; | ||||
1136 | } | ||||
1137 | |||||
1138 | 635 | 248µs | return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ; | ||
1139 | |||||
1140 | # the core read will return 0 if asked for 0 bytes | ||||
1141 | 635 | 166µs | return 0 if defined $length && $length == 0 ; | ||
1142 | |||||
1143 | 635 | 134µs | $length = $length || 0; | ||
1144 | |||||
1145 | 635 | 129µs | $self->croakError(*$self->{ClassName} . "::read: length parameter is negative") | ||
1146 | if $length < 0 ; | ||||
1147 | |||||
1148 | # Short-circuit if this is a simple read, with no length | ||||
1149 | # or offset specified. | ||||
1150 | 635 | 73µs | unless ( $length || $offset) { | ||
1151 | 3 | 1µs | if (length *$self->{Pending}) { | ||
1152 | $$buffer .= *$self->{Pending} ; | ||||
1153 | my $len = length *$self->{Pending}; | ||||
1154 | *$self->{Pending} = '' ; | ||||
1155 | return $len ; | ||||
1156 | } | ||||
1157 | else { | ||||
1158 | 3 | 2µs | my $len = 0; | ||
1159 | $len = $self->_raw_read($buffer) | ||||
1160 | 3 | 178µs | 3 | 2.69ms | while ! *$self->{EndStream} && $len == 0 ; # spent 2.69ms making 3 calls to IO::Uncompress::Base::_raw_read, avg 897µs/call |
1161 | 3 | 10µs | return $len ; | ||
1162 | } | ||||
1163 | } | ||||
1164 | |||||
1165 | # Need to jump through more hoops - either length or offset | ||||
1166 | # or both are specified. | ||||
1167 | 632 | 476µs | my $out_buffer = *$self->{Pending} ; | ||
1168 | 632 | 173µs | *$self->{Pending} = ''; | ||
1169 | |||||
1170 | |||||
1171 | 632 | 342µs | while (! *$self->{EndStream} && length($out_buffer) < $length) | ||
1172 | { | ||||
1173 | 628 | 868µs | 628 | 111ms | my $buf_len = $self->_raw_read(\$out_buffer); # spent 111ms making 628 calls to IO::Uncompress::Base::_raw_read, avg 177µs/call |
1174 | 628 | 609µs | return $buf_len | ||
1175 | if $buf_len < 0 ; | ||||
1176 | } | ||||
1177 | |||||
1178 | 632 | 129µs | $length = length $out_buffer | ||
1179 | if length($out_buffer) < $length ; | ||||
1180 | |||||
1181 | 632 | 102µs | return 0 | ||
1182 | if $length == 0 ; | ||||
1183 | |||||
1184 | 632 | 157µs | $$buffer = '' | ||
1185 | if ! defined $$buffer; | ||||
1186 | |||||
1187 | $offset = length $$buffer | ||||
1188 | 632 | 157µs | if *$self->{AppendOutput} ; | ||
1189 | |||||
1190 | 632 | 597µs | *$self->{Pending} = $out_buffer; | ||
1191 | 632 | 581µs | $out_buffer = \*$self->{Pending} ; | ||
1192 | |||||
1193 | 632 | 715µs | substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ; | ||
1194 | 632 | 178µs | substr($$out_buffer, 0, $length) = '' ; | ||
1195 | |||||
1196 | 632 | 1.50ms | return $length ; | ||
1197 | } | ||||
1198 | |||||
1199 | sub _getline | ||||
1200 | { | ||||
1201 | my $self = shift ; | ||||
1202 | my $status = 0 ; | ||||
1203 | |||||
1204 | # Slurp Mode | ||||
1205 | if ( ! defined $/ ) { | ||||
1206 | my $data ; | ||||
1207 | 1 while ($status = $self->read($data)) > 0 ; | ||||
1208 | return ($status, \$data); | ||||
1209 | } | ||||
1210 | |||||
1211 | # Record Mode | ||||
1212 | if ( ref $/ eq 'SCALAR' && ${$/} =~ /^\d+$/ && ${$/} > 0) { | ||||
1213 | my $reclen = ${$/} ; | ||||
1214 | my $data ; | ||||
1215 | $status = $self->read($data, $reclen) ; | ||||
1216 | return ($status, \$data); | ||||
1217 | } | ||||
1218 | |||||
1219 | # Paragraph Mode | ||||
1220 | if ( ! length $/ ) { | ||||
1221 | my $paragraph ; | ||||
1222 | while (($status = $self->read($paragraph)) > 0 ) { | ||||
1223 | if ($paragraph =~ s/^(.*?\n\n+)//s) { | ||||
1224 | *$self->{Pending} = $paragraph ; | ||||
1225 | my $par = $1 ; | ||||
1226 | return (1, \$par); | ||||
1227 | } | ||||
1228 | } | ||||
1229 | return ($status, \$paragraph); | ||||
1230 | } | ||||
1231 | |||||
1232 | # $/ isn't empty, or a reference, so it's Line Mode. | ||||
1233 | { | ||||
1234 | my $line ; | ||||
1235 | my $p = \*$self->{Pending} ; | ||||
1236 | while (($status = $self->read($line)) > 0 ) { | ||||
1237 | my $offset = index($line, $/); | ||||
1238 | if ($offset >= 0) { | ||||
1239 | my $l = substr($line, 0, $offset + length $/ ); | ||||
1240 | substr($line, 0, $offset + length $/) = ''; | ||||
1241 | $$p = $line; | ||||
1242 | return (1, \$l); | ||||
1243 | } | ||||
1244 | } | ||||
1245 | |||||
1246 | return ($status, \$line); | ||||
1247 | } | ||||
1248 | } | ||||
1249 | |||||
1250 | sub getline | ||||
1251 | { | ||||
1252 | my $self = shift; | ||||
1253 | |||||
1254 | if (defined *$self->{ReadStatus} ) { | ||||
1255 | $self->saveErrorString( @{ *$self->{ReadStatus} } ); | ||||
1256 | delete *$self->{ReadStatus} ; | ||||
1257 | return undef; | ||||
1258 | } | ||||
1259 | |||||
1260 | return undef | ||||
1261 | if *$self->{Closed} || (!length *$self->{Pending} && *$self->{EndStream}) ; | ||||
1262 | |||||
1263 | my $current_append = *$self->{AppendOutput} ; | ||||
1264 | *$self->{AppendOutput} = 1; | ||||
1265 | |||||
1266 | my ($status, $lineref) = $self->_getline(); | ||||
1267 | *$self->{AppendOutput} = $current_append; | ||||
1268 | |||||
1269 | return undef | ||||
1270 | if $status < 0 || length $$lineref == 0 ; | ||||
1271 | |||||
1272 | $. = ++ *$self->{LineNo} ; | ||||
1273 | |||||
1274 | return $$lineref ; | ||||
1275 | } | ||||
1276 | |||||
1277 | sub getlines | ||||
1278 | { | ||||
1279 | my $self = shift; | ||||
1280 | $self->croakError(*$self->{ClassName} . | ||||
1281 | "::getlines: called in scalar context\n") unless wantarray; | ||||
1282 | my($line, @lines); | ||||
1283 | push(@lines, $line) | ||||
1284 | while defined($line = $self->getline); | ||||
1285 | return @lines; | ||||
1286 | } | ||||
1287 | |||||
1288 | sub READLINE | ||||
1289 | { | ||||
1290 | goto &getlines if wantarray; | ||||
1291 | goto &getline; | ||||
1292 | } | ||||
1293 | |||||
1294 | sub getc | ||||
1295 | { | ||||
1296 | my $self = shift; | ||||
1297 | my $buf; | ||||
1298 | return $buf if $self->read($buf, 1); | ||||
1299 | return undef; | ||||
1300 | } | ||||
1301 | |||||
1302 | sub ungetc | ||||
1303 | # spent 40µs within IO::Uncompress::Base::ungetc which was called 3 times, avg 13µs/call:
# 3 times (40µs+0s) by IO::Uncompress::Base::_create at line 510, avg 13µs/call | ||||
1304 | 3 | 9µs | my $self = shift; | ||
1305 | 3 | 2µs | *$self->{Pending} = "" unless defined *$self->{Pending} ; | ||
1306 | 3 | 36µs | *$self->{Pending} = $_[0] . *$self->{Pending} ; | ||
1307 | } | ||||
1308 | |||||
1309 | |||||
1310 | sub trailingData | ||||
1311 | { | ||||
1312 | my $self = shift ; | ||||
1313 | |||||
1314 | if (defined *$self->{FH} || defined *$self->{InputEvent} ) { | ||||
1315 | return *$self->{Prime} ; | ||||
1316 | } | ||||
1317 | else { | ||||
1318 | my $buf = *$self->{Buffer} ; | ||||
1319 | my $offset = *$self->{BufferOffset} ; | ||||
1320 | return substr($$buf, $offset) ; | ||||
1321 | } | ||||
1322 | } | ||||
1323 | |||||
1324 | |||||
1325 | sub eof | ||||
1326 | # spent 4.49ms (4.19+299µs) within IO::Uncompress::Base::eof which was called 2539 times, avg 2µs/call:
# 1271 times (2.21ms+156µs) by Compress::Zlib::_save_gzerr at line 97 of Compress/Zlib.pm, avg 2µs/call
# 634 times (1.01ms+99µs) by Compress::Zlib::_save_gzerr at line 99 of Compress/Zlib.pm, avg 2µs/call
# 634 times (976µs+44µs) by Compress::Zlib::gzFile::gzeof at line 268 of Compress/Zlib.pm, avg 2µs/call | ||||
1327 | 2539 | 475µs | my $self = shift ; | ||
1328 | |||||
1329 | return (*$self->{Closed} || | ||||
1330 | (!length *$self->{Pending} | ||||
1331 | 2539 | 13.7ms | 12 | 299µs | && ( $self->smartEof() || *$self->{EndStream}))) ; # spent 299µs making 12 calls to IO::Uncompress::Base::smartEof, avg 25µs/call |
1332 | } | ||||
1333 | |||||
1334 | sub tell | ||||
1335 | { | ||||
1336 | my $self = shift ; | ||||
1337 | |||||
1338 | my $in ; | ||||
1339 | if (*$self->{Plain}) { | ||||
1340 | $in = *$self->{PlainBytesRead} ; | ||||
1341 | } | ||||
1342 | else { | ||||
1343 | $in = *$self->{TotalInflatedBytesRead} ; | ||||
1344 | } | ||||
1345 | |||||
1346 | my $pending = length *$self->{Pending} ; | ||||
1347 | |||||
1348 | return 0 if $pending > $in ; | ||||
1349 | return $in - $pending ; | ||||
1350 | } | ||||
1351 | |||||
1352 | sub close | ||||
1353 | # spent 253µs (162+91) within IO::Uncompress::Base::close which was called 6 times, avg 42µs/call:
# 3 times (156µs+91µs) by Compress::Zlib::gzFile::gzclose at line 255 of Compress/Zlib.pm, avg 82µs/call
# 3 times (6µs+0s) by IO::Uncompress::Base::DESTROY at line 1386, avg 2µs/call | ||||
1354 | # todo - what to do if close is called before the end of the gzip file | ||||
1355 | # do we remember any trailing data? | ||||
1356 | 6 | 11µs | my $self = shift ; | ||
1357 | |||||
1358 | 6 | 23µs | return 1 if *$self->{Closed} ; | ||
1359 | |||||
1360 | 3 | 20µs | 3 | 5µs | untie *$self # spent 5µs making 3 calls to IO::Uncompress::Base::UNTIE, avg 2µs/call |
1361 | if $] >= 5.008 ; | ||||
1362 | |||||
1363 | 3 | 1µs | my $status = 1 ; | ||
1364 | |||||
1365 | 3 | 2µs | if (defined *$self->{FH}) { | ||
1366 | 3 | 12µs | if ((! *$self->{Handle} || *$self->{AutoClose}) && ! *$self->{StdIO}) { | ||
1367 | 3 | 6µs | local $.; | ||
1368 | 3 | 8µs | $! = 0 ; | ||
1369 | 3 | 17µs | 3 | 72µs | $status = *$self->{FH}->close(); # spent 72µs making 3 calls to IO::Handle::close, avg 24µs/call |
1370 | return $self->saveErrorString(0, $!, $!) | ||||
1371 | 3 | 15µs | 3 | 14µs | if !*$self->{InNew} && $self->saveStatus($!) != 0 ; # spent 14µs making 3 calls to IO::Uncompress::Base::saveStatus, avg 5µs/call |
1372 | } | ||||
1373 | 3 | 13µs | delete *$self->{FH} ; | ||
1374 | 3 | 3µs | $! = 0 ; | ||
1375 | } | ||||
1376 | 3 | 3µs | *$self->{Closed} = 1 ; | ||
1377 | |||||
1378 | 3 | 10µs | return 1; | ||
1379 | } | ||||
1380 | |||||
1381 | sub DESTROY | ||||
1382 | # spent 60µs (54+6) within IO::Uncompress::Base::DESTROY which was called 3 times, avg 20µs/call:
# 2 times (37µs+4µs) by CPAN::Tarzip::gtest at line 158 of CPAN/Tarzip.pm, avg 20µs/call
# once (17µs+2µs) by CPAN::Distribution::CHECKSUM_check_file at line 1508 of CPAN/Distribution.pm | ||||
1383 | 3 | 9µs | my $self = shift ; | ||
1384 | 3 | 23µs | local ($., $@, $!, $^E, $?); | ||
1385 | |||||
1386 | 3 | 30µs | 3 | 6µs | $self->close() ; # spent 6µs making 3 calls to IO::Uncompress::Base::close, avg 2µs/call |
1387 | } | ||||
1388 | |||||
1389 | sub seek | ||||
1390 | { | ||||
1391 | my $self = shift ; | ||||
1392 | my $position = shift; | ||||
1393 | my $whence = shift ; | ||||
1394 | |||||
1395 | my $here = $self->tell() ; | ||||
1396 | my $target = 0 ; | ||||
1397 | |||||
1398 | |||||
1399 | if ($whence == SEEK_SET) { | ||||
1400 | $target = $position ; | ||||
1401 | } | ||||
1402 | elsif ($whence == SEEK_CUR) { | ||||
1403 | $target = $here + $position ; | ||||
1404 | } | ||||
1405 | elsif ($whence == SEEK_END) { | ||||
1406 | $target = $position ; | ||||
1407 | $self->croakError(*$self->{ClassName} . "::seek: SEEK_END not allowed") ; | ||||
1408 | } | ||||
1409 | else { | ||||
1410 | $self->croakError(*$self->{ClassName} ."::seek: unknown value, $whence, for whence parameter"); | ||||
1411 | } | ||||
1412 | |||||
1413 | # short circuit if seeking to current offset | ||||
1414 | if ($target == $here) { | ||||
1415 | # On ordinary filehandles, seeking to the current | ||||
1416 | # position also clears the EOF condition, so we | ||||
1417 | # emulate this behavior locally while simultaneously | ||||
1418 | # cascading it to the underlying filehandle | ||||
1419 | if (*$self->{Plain}) { | ||||
1420 | *$self->{EndStream} = 0; | ||||
1421 | seek(*$self->{FH},0,1) if *$self->{FH}; | ||||
1422 | } | ||||
1423 | return 1; | ||||
1424 | } | ||||
1425 | |||||
1426 | # Outlaw any attempt to seek backwards | ||||
1427 | $self->croakError( *$self->{ClassName} ."::seek: cannot seek backwards") | ||||
1428 | if $target < $here ; | ||||
1429 | |||||
1430 | # Walk the file to the new offset | ||||
1431 | my $offset = $target - $here ; | ||||
1432 | |||||
1433 | my $got; | ||||
1434 | while (($got = $self->read(my $buffer, List::Util::min($offset, *$self->{BlockSize})) ) > 0) | ||||
1435 | { | ||||
1436 | $offset -= $got; | ||||
1437 | last if $offset == 0 ; | ||||
1438 | } | ||||
1439 | |||||
1440 | $here = $self->tell() ; | ||||
1441 | return $offset == 0 ? 1 : 0 ; | ||||
1442 | } | ||||
1443 | |||||
1444 | sub fileno | ||||
1445 | { | ||||
1446 | my $self = shift ; | ||||
1447 | return defined *$self->{FH} | ||||
1448 | ? fileno *$self->{FH} | ||||
1449 | : undef ; | ||||
1450 | } | ||||
1451 | |||||
1452 | sub binmode | ||||
1453 | { | ||||
1454 | 1; | ||||
1455 | # my $self = shift ; | ||||
1456 | # return defined *$self->{FH} | ||||
1457 | # ? binmode *$self->{FH} | ||||
1458 | # : 1 ; | ||||
1459 | } | ||||
1460 | |||||
1461 | sub opened | ||||
1462 | { | ||||
1463 | my $self = shift ; | ||||
1464 | return ! *$self->{Closed} ; | ||||
1465 | } | ||||
1466 | |||||
1467 | sub autoflush | ||||
1468 | { | ||||
1469 | my $self = shift ; | ||||
1470 | return defined *$self->{FH} | ||||
1471 | ? *$self->{FH}->autoflush(@_) | ||||
1472 | : undef ; | ||||
1473 | } | ||||
1474 | |||||
1475 | sub input_line_number | ||||
1476 | { | ||||
1477 | my $self = shift ; | ||||
1478 | my $last = *$self->{LineNo}; | ||||
1479 | $. = *$self->{LineNo} = $_[1] if @_ ; | ||||
1480 | return $last; | ||||
1481 | } | ||||
1482 | |||||
1483 | |||||
1484 | 1 | 3µs | *BINMODE = \&binmode; | ||
1485 | 1 | 0s | *SEEK = \&seek; | ||
1486 | 1 | 1µs | *READ = \&read; | ||
1487 | 1 | 0s | *sysread = \&read; | ||
1488 | 1 | 1µs | *TELL = \&tell; | ||
1489 | 1 | 0s | *EOF = \&eof; | ||
1490 | |||||
1491 | 1 | 0s | *FILENO = \&fileno; | ||
1492 | 1 | 1µs | *CLOSE = \&close; | ||
1493 | |||||
1494 | sub _notAvailable | ||||
1495 | # spent 16µs within IO::Uncompress::Base::_notAvailable which was called 6 times, avg 3µs/call:
# once (6µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 1501
# once (3µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 1502
# once (2µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 1506
# once (2µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 1505
# once (2µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 1504
# once (1µs+0s) by IO::Uncompress::RawInflate::BEGIN@11 at line 1503 | ||||
1496 | 6 | 2µs | my $name = shift ; | ||
1497 | 6 | 33µs | return sub { croak "$name Not Available: File opened only for intput" ; } ; | ||
1498 | } | ||||
1499 | |||||
1500 | |||||
1501 | 1 | 3µs | 1 | 6µs | *print = _notAvailable('print'); # spent 6µs making 1 call to IO::Uncompress::Base::_notAvailable |
1502 | 1 | 2µs | 1 | 3µs | *PRINT = _notAvailable('print'); # spent 3µs making 1 call to IO::Uncompress::Base::_notAvailable |
1503 | 1 | 0s | 1 | 1µs | *printf = _notAvailable('printf'); # spent 1µs making 1 call to IO::Uncompress::Base::_notAvailable |
1504 | 1 | 0s | 1 | 2µs | *PRINTF = _notAvailable('printf'); # spent 2µs making 1 call to IO::Uncompress::Base::_notAvailable |
1505 | 1 | 2µs | 1 | 2µs | *write = _notAvailable('write'); # spent 2µs making 1 call to IO::Uncompress::Base::_notAvailable |
1506 | 1 | 0s | 1 | 2µs | *WRITE = _notAvailable('write'); # spent 2µs making 1 call to IO::Uncompress::Base::_notAvailable |
1507 | |||||
1508 | #*sysread = \&read; | ||||
1509 | #*syswrite = \&_notAvailable; | ||||
1510 | |||||
- - | |||||
1513 | package IO::Uncompress::Base ; | ||||
1514 | |||||
1515 | |||||
1516 | 1 | 16µs | 1 ; | ||
1517 | __END__ |