| Filename | /usr/local/perls/perl-5.26.1/lib/5.26.1/Compress/Zlib.pm |
| Statements | Executed 21726 statements in 30.0ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1271 | 4 | 1 | 22.5ms | 29.5ms | Compress::Zlib::_save_gzerr |
| 1 | 1 | 1 | 7.38ms | 15.1ms | Compress::Zlib::BEGIN@10 |
| 634 | 2 | 1 | 5.62ms | 162ms | Compress::Zlib::gzFile::gzread |
| 1 | 1 | 1 | 4.57ms | 7.93ms | Compress::Zlib::BEGIN@11 |
| 634 | 1 | 1 | 3.87ms | 16.1ms | Compress::Zlib::gzFile::gzeof |
| 1 | 1 | 1 | 2.44ms | 19.8ms | Compress::Zlib::BEGIN@12 |
| 1 | 1 | 1 | 2.38ms | 17.5ms | Compress::Zlib::BEGIN@13 |
| 1274 | 2 | 1 | 2.07ms | 2.15ms | Compress::Zlib::_set_gzerr |
| 3 | 2 | 1 | 603µs | 14.2ms | Compress::Zlib::gzopen |
| 3 | 2 | 1 | 49µs | 345µs | Compress::Zlib::gzFile::gzclose |
| 21 | 7 | 1 | 37µs | 37µs | Compress::Zlib::CORE:match (opcode) |
| 1 | 1 | 1 | 27µs | 100µs | Compress::Zlib::BEGIN@6 |
| 1 | 1 | 1 | 23µs | 295µs | Compress::Zlib::BEGIN@464 |
| 1 | 1 | 1 | 15µs | 34µs | Compress::Zlib::BEGIN@7 |
| 1 | 1 | 1 | 13µs | 16µs | Compress::Zlib::BEGIN@15 |
| 1 | 1 | 1 | 11µs | 39µs | Compress::Zlib::BEGIN@8 |
| 1 | 1 | 1 | 10µs | 21µs | Compress::Zlib::BEGIN@16 |
| 1 | 1 | 1 | 10µs | 12µs | Compress::Zlib::BEGIN@17 |
| 1 | 1 | 1 | 9µs | 44µs | Compress::Zlib::BEGIN@49 |
| 1 | 1 | 1 | 8µs | 64µs | Compress::Zlib::BEGIN@48 |
| 1 | 1 | 1 | 8µs | 47µs | Compress::Zlib::BEGIN@50 |
| 1 | 1 | 1 | 8µs | 43µs | Compress::Zlib::BEGIN@51 |
| 1 | 1 | 1 | 7µs | 7µs | Compress::Zlib::BEGIN@44 |
| 2 | 1 | 1 | 7µs | 7µs | Compress::Zlib::gzFile::gzerror |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::_removeGzipHeader |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::_ret_gun_error |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::_set_gzerr_undef |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::compress |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::deflateInit |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::gzFile::gzflush |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::gzFile::gzreadline |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::gzFile::gzseek |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::gzFile::gzsetparams |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::gzFile::gztell |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::gzFile::gzwrite |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::inflateInit |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::memGunzip |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::memGzip |
| 0 | 0 | 0 | 0s | 0s | Compress::Zlib::uncompress |
| 0 | 0 | 0 | 0s | 0s | Zlib::OldDeflate::deflate |
| 0 | 0 | 0 | 0s | 0s | Zlib::OldDeflate::flush |
| 0 | 0 | 0 | 0s | 0s | Zlib::OldInflate::inflate |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Compress::Zlib; | ||||
| 3 | |||||
| 4 | 1 | 10µs | require 5.006 ; | ||
| 5 | 1 | 1µs | require Exporter; | ||
| 6 | 2 | 43µs | 2 | 173µs | # spent 100µs (27+73) within Compress::Zlib::BEGIN@6 which was called:
# once (27µs+73µs) by CPAN::has_inst at line 6 # spent 100µs making 1 call to Compress::Zlib::BEGIN@6
# spent 73µs making 1 call to Exporter::import |
| 7 | 2 | 39µs | 2 | 53µs | # spent 34µs (15+19) within Compress::Zlib::BEGIN@7 which was called:
# once (15µs+19µs) by CPAN::has_inst at line 7 # spent 34µs making 1 call to Compress::Zlib::BEGIN@7
# spent 19µs making 1 call to Exporter::import |
| 8 | 2 | 40µs | 2 | 67µs | # spent 39µs (11+28) within Compress::Zlib::BEGIN@8 which was called:
# once (11µs+28µs) by CPAN::has_inst at line 8 # spent 39µs making 1 call to Compress::Zlib::BEGIN@8
# spent 28µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 3 | 822µs | 3 | 15.2ms | # spent 15.1ms (7.38+7.67) within Compress::Zlib::BEGIN@10 which was called:
# once (7.38ms+7.67ms) by CPAN::has_inst at line 10 # spent 15.1ms making 1 call to Compress::Zlib::BEGIN@10
# spent 139µs making 1 call to Exporter::import
# spent 15µs making 1 call to version::_VERSION |
| 11 | 3 | 642µs | 3 | 8.17ms | # spent 7.93ms (4.57+3.36) within Compress::Zlib::BEGIN@11 which was called:
# once (4.57ms+3.36ms) by CPAN::has_inst at line 11 # spent 7.93ms making 1 call to Compress::Zlib::BEGIN@11
# spent 224µs making 1 call to Exporter::import
# spent 14µs making 1 call to version::_VERSION |
| 12 | 3 | 524µs | 3 | 19.8ms | # spent 19.8ms (2.44+17.3) within Compress::Zlib::BEGIN@12 which was called:
# once (2.44ms+17.3ms) by CPAN::has_inst at line 12 # spent 19.8ms making 1 call to Compress::Zlib::BEGIN@12
# spent 24µs making 1 call to Exporter::import
# spent 10µs making 1 call to version::_VERSION |
| 13 | 3 | 598µs | 3 | 17.6ms | # spent 17.5ms (2.38+15.2) within Compress::Zlib::BEGIN@13 which was called:
# once (2.38ms+15.2ms) by CPAN::has_inst at line 13 # spent 17.5ms making 1 call to Compress::Zlib::BEGIN@13
# spent 19µs making 1 call to Exporter::import
# spent 10µs making 1 call to version::_VERSION |
| 14 | |||||
| 15 | 2 | 31µs | 2 | 19µs | # spent 16µs (13+3) within Compress::Zlib::BEGIN@15 which was called:
# once (13µs+3µs) by CPAN::has_inst at line 15 # spent 16µs making 1 call to Compress::Zlib::BEGIN@15
# spent 3µs making 1 call to strict::import |
| 16 | 2 | 28µs | 2 | 32µs | # spent 21µs (10+11) within Compress::Zlib::BEGIN@16 which was called:
# once (10µs+11µs) by CPAN::has_inst at line 16 # spent 21µs making 1 call to Compress::Zlib::BEGIN@16
# spent 11µs making 1 call to warnings::import |
| 17 | 2 | 149µs | 2 | 14µs | # spent 12µs (10+2) within Compress::Zlib::BEGIN@17 which was called:
# once (10µs+2µs) by CPAN::has_inst at line 17 # spent 12µs making 1 call to Compress::Zlib::BEGIN@17
# spent 2µs making 1 call to bytes::import |
| 18 | our ($VERSION, $XS_VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); | ||||
| 19 | |||||
| 20 | 1 | 0s | $VERSION = '2.074'; | ||
| 21 | 1 | 1µs | $XS_VERSION = $VERSION; | ||
| 22 | 1 | 17µs | $VERSION = eval $VERSION; # spent 4µs executing statements in string eval | ||
| 23 | |||||
| 24 | 1 | 9µs | @ISA = qw(Exporter); | ||
| 25 | # Items to export into callers namespace by default. Note: do not export | ||||
| 26 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||
| 27 | # Do not simply export all your public functions/methods/constants. | ||||
| 28 | 1 | 1µs | @EXPORT = qw( | ||
| 29 | deflateInit inflateInit | ||||
| 30 | |||||
| 31 | compress uncompress | ||||
| 32 | |||||
| 33 | gzopen $gzerrno | ||||
| 34 | ); | ||||
| 35 | |||||
| 36 | 1 | 11µs | push @EXPORT, @Compress::Raw::Zlib::EXPORT ; | ||
| 37 | |||||
| 38 | 1 | 0s | @EXPORT_OK = qw(memGunzip memGzip zlib_version); | ||
| 39 | 1 | 2µs | %EXPORT_TAGS = ( | ||
| 40 | ALL => \@EXPORT | ||||
| 41 | ); | ||||
| 42 | |||||
| 43 | BEGIN | ||||
| 44 | # spent 7µs within Compress::Zlib::BEGIN@44 which was called:
# once (7µs+0s) by CPAN::has_inst at line 46 | ||||
| 45 | 1 | 7µs | *zlib_version = \&Compress::Raw::Zlib::zlib_version; | ||
| 46 | 1 | 32µs | 1 | 7µs | } # spent 7µs making 1 call to Compress::Zlib::BEGIN@44 |
| 47 | |||||
| 48 | 2 | 35µs | 2 | 120µs | # spent 64µs (8+56) within Compress::Zlib::BEGIN@48 which was called:
# once (8µs+56µs) by CPAN::has_inst at line 48 # spent 64µs making 1 call to Compress::Zlib::BEGIN@48
# spent 56µs making 1 call to constant::import |
| 49 | 2 | 32µs | 2 | 79µs | # spent 44µs (9+35) within Compress::Zlib::BEGIN@49 which was called:
# once (9µs+35µs) by CPAN::has_inst at line 49 # spent 44µs making 1 call to Compress::Zlib::BEGIN@49
# spent 35µs making 1 call to constant::import |
| 50 | 2 | 31µs | 2 | 86µs | # spent 47µs (8+39) within Compress::Zlib::BEGIN@50 which was called:
# once (8µs+39µs) by CPAN::has_inst at line 50 # spent 47µs making 1 call to Compress::Zlib::BEGIN@50
# spent 39µs making 1 call to constant::import |
| 51 | 2 | 2.71ms | 2 | 78µs | # spent 43µs (8+35) within Compress::Zlib::BEGIN@51 which was called:
# once (8µs+35µs) by CPAN::has_inst at line 51 # spent 43µs making 1 call to Compress::Zlib::BEGIN@51
# spent 35µs making 1 call to constant::import |
| 52 | |||||
| 53 | our (@my_z_errmsg); | ||||
| 54 | |||||
| 55 | 1 | 1µs | @my_z_errmsg = ( | ||
| 56 | "need dictionary", # Z_NEED_DICT 2 | ||||
| 57 | "stream end", # Z_STREAM_END 1 | ||||
| 58 | "", # Z_OK 0 | ||||
| 59 | "file error", # Z_ERRNO (-1) | ||||
| 60 | "stream error", # Z_STREAM_ERROR (-2) | ||||
| 61 | "data error", # Z_DATA_ERROR (-3) | ||||
| 62 | "insufficient memory", # Z_MEM_ERROR (-4) | ||||
| 63 | "buffer error", # Z_BUF_ERROR (-5) | ||||
| 64 | "incompatible version",# Z_VERSION_ERROR(-6) | ||||
| 65 | ); | ||||
| 66 | |||||
| 67 | |||||
| 68 | sub _set_gzerr | ||||
| 69 | { | ||||
| 70 | 1274 | 245µs | my $value = shift ; | ||
| 71 | |||||
| 72 | 1274 | 431µs | 10 | 50µs | if ($value == 0) { # spent 40µs making 1 call to Compress::Raw::Zlib::AUTOLOAD
# spent 10µs making 9 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:114], avg 1µs/call |
| 73 | 1264 | 267µs | $Compress::Zlib::gzerrno = 0 ; | ||
| 74 | } | ||||
| 75 | elsif ($value == Z_ERRNO() || $value > 2) { | ||||
| 76 | $Compress::Zlib::gzerrno = $! ; | ||||
| 77 | } | ||||
| 78 | else { | ||||
| 79 | 10 | 53µs | 10 | 23µs | $Compress::Zlib::gzerrno = dualvar($value+0, $my_z_errmsg[2 - $value]); # spent 23µs making 10 calls to Scalar::Util::dualvar, avg 2µs/call |
| 80 | } | ||||
| 81 | |||||
| 82 | 1274 | 5.76ms | return $value ; | ||
| 83 | } | ||||
| 84 | |||||
| 85 | sub _set_gzerr_undef | ||||
| 86 | { | ||||
| 87 | _set_gzerr(@_); | ||||
| 88 | return undef; | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | sub _save_gzerr | ||||
| 92 | # spent 29.5ms (22.5+7.00) within Compress::Zlib::_save_gzerr which was called 1271 times, avg 23µs/call:
# 634 times (8.60ms+2.65ms) by Compress::Zlib::gzFile::gzeof at line 269, avg 18µs/call
# 632 times (13.8ms+4.21ms) by Compress::Zlib::gzFile::gzread at line 175, avg 29µs/call
# 3 times (26µs+23µs) by Compress::Zlib::gzFile::gzclose at line 256, avg 16µs/call
# 2 times (17µs+125µs) by Compress::Zlib::gzFile::gzread at line 170, avg 71µs/call | ||||
| 93 | 1271 | 274µs | my $gz = shift ; | ||
| 94 | 1271 | 177µs | my $test_eof = shift ; | ||
| 95 | |||||
| 96 | 1271 | 1.74ms | 1271 | 1.43ms | my $value = $gz->errorNo() || 0 ; # spent 1.43ms making 1271 calls to IO::Uncompress::Base::errorNo, avg 1µs/call |
| 97 | 1271 | 1.67ms | 1271 | 2.37ms | my $eof = $gz->eof() ; # spent 2.37ms making 1271 calls to IO::Uncompress::Base::eof, avg 2µs/call |
| 98 | |||||
| 99 | 1271 | 933µs | 634 | 1.10ms | if ($test_eof) { # spent 1.10ms making 634 calls to IO::Uncompress::Base::eof, avg 2µs/call |
| 100 | # gzread uses Z_STREAM_END to denote a successful end | ||||
| 101 | $value = Z_STREAM_END() if $gz->eof() && $value == 0 ; | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | 1271 | 3.30ms | 1271 | 2.11ms | _set_gzerr($value) ; # spent 2.11ms making 1271 calls to Compress::Zlib::_set_gzerr, avg 2µs/call |
| 105 | } | ||||
| 106 | |||||
| 107 | sub gzopen($$) | ||||
| 108 | # spent 14.2ms (603µs+13.6) within Compress::Zlib::gzopen which was called 3 times, avg 4.74ms/call:
# 2 times (561µs+11.8ms) by CPAN::Tarzip::gtest at line 143 of CPAN/Tarzip.pm, avg 6.17ms/call
# once (42µs+1.83ms) by CPAN::Tarzip::TIEHANDLE at line 187 of CPAN/Tarzip.pm | ||||
| 109 | 3 | 6µs | my ($file, $mode) = @_ ; | ||
| 110 | |||||
| 111 | 3 | 13µs | my $gz ; | ||
| 112 | 3 | 167µs | 6 | 60µs | my %defOpts = (Level => Z_DEFAULT_COMPRESSION(), # spent 60µs making 6 calls to Compress::Raw::Zlib::__ANON__[Compress/Raw/Zlib.pm:114], avg 10µs/call |
| 113 | Strategy => Z_DEFAULT_STRATEGY(), | ||||
| 114 | ); | ||||
| 115 | |||||
| 116 | 3 | 1µs | my $writing ; | ||
| 117 | 3 | 71µs | 3 | 14µs | $writing = ! ($mode =~ /r/i) ; # spent 14µs making 3 calls to Compress::Zlib::CORE:match, avg 5µs/call |
| 118 | 3 | 28µs | 3 | 5µs | $writing = ($mode =~ /[wa]/i) ; # spent 5µs making 3 calls to Compress::Zlib::CORE:match, avg 2µs/call |
| 119 | |||||
| 120 | 3 | 15µs | 3 | 4µs | $defOpts{Level} = $1 if $mode =~ /(\d)/; # spent 4µs making 3 calls to Compress::Zlib::CORE:match, avg 1µs/call |
| 121 | 3 | 10µs | 3 | 2µs | $defOpts{Strategy} = Z_FILTERED() if $mode =~ /f/i; # spent 2µs making 3 calls to Compress::Zlib::CORE:match, avg 667ns/call |
| 122 | 3 | 11µs | 3 | 2µs | $defOpts{Strategy} = Z_HUFFMAN_ONLY() if $mode =~ /h/i; # spent 2µs making 3 calls to Compress::Zlib::CORE:match, avg 667ns/call |
| 123 | 3 | 9µs | 3 | 2µs | $defOpts{Append} = 1 if $mode =~ /a/i; # spent 2µs making 3 calls to Compress::Zlib::CORE:match, avg 667ns/call |
| 124 | |||||
| 125 | 3 | 14µs | my $infDef = $writing ? 'deflate' : 'inflate'; | ||
| 126 | 3 | 2µs | my @params = () ; | ||
| 127 | |||||
| 128 | 3 | 100µs | 6 | 205µs | croak "gzopen: file parameter is not a filehandle or filename" # spent 137µs making 3 calls to IO::Compress::Base::Common::isaFilehandle, avg 46µs/call
# spent 68µs making 3 calls to IO::Compress::Base::Common::isaFilename, avg 23µs/call |
| 129 | unless isaFilehandle $file || isaFilename $file || | ||||
| 130 | (ref $file && ref $file eq 'SCALAR'); | ||||
| 131 | |||||
| 132 | 3 | 34µs | 3 | 8µs | return undef unless $mode =~ /[rwa]/i ; # spent 8µs making 3 calls to Compress::Zlib::CORE:match, avg 3µs/call |
| 133 | |||||
| 134 | 3 | 25µs | 3 | 41µs | _set_gzerr(0) ; # spent 41µs making 3 calls to Compress::Zlib::_set_gzerr, avg 14µs/call |
| 135 | |||||
| 136 | 3 | 0s | if ($writing) { | ||
| 137 | $gz = new IO::Compress::Gzip($file, Minimal => 1, AutoClose => 1, | ||||
| 138 | %defOpts) | ||||
| 139 | or $Compress::Zlib::gzerrno = $IO::Compress::Gzip::GzipError; | ||||
| 140 | } | ||||
| 141 | else { | ||||
| 142 | 3 | 175µs | 3 | 13.3ms | $gz = new IO::Uncompress::Gunzip($file, # spent 13.3ms making 3 calls to IO::Uncompress::Gunzip::new, avg 4.42ms/call |
| 143 | Transparent => 1, | ||||
| 144 | Append => 0, | ||||
| 145 | AutoClose => 1, | ||||
| 146 | MultiStream => 1, | ||||
| 147 | Strict => 0) | ||||
| 148 | or $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError; | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | return undef | ||||
| 152 | 3 | 1µs | if ! defined $gz ; | ||
| 153 | |||||
| 154 | 3 | 45µs | bless [$gz, $infDef], 'Compress::Zlib::gzFile'; | ||
| 155 | } | ||||
| 156 | |||||
| 157 | sub Compress::Zlib::gzFile::gzread | ||||
| 158 | # spent 162ms (5.62+156) within Compress::Zlib::gzFile::gzread which was called 634 times, avg 256µs/call:
# 632 times (5.56ms+156ms) by CPAN::Tarzip::gtest at line 149 of CPAN/Tarzip.pm, avg 256µs/call
# 2 times (61µs+257µs) by CPAN::Tarzip::gtest at line 147 of CPAN/Tarzip.pm, avg 159µs/call | ||||
| 159 | 634 | 123µs | my $self = shift ; | ||
| 160 | |||||
| 161 | 634 | 315µs | return _set_gzerr(Z_STREAM_ERROR()) | ||
| 162 | if $self->[1] ne 'inflate'; | ||||
| 163 | |||||
| 164 | 634 | 191µs | my $len = defined $_[1] ? $_[1] : 4096 ; | ||
| 165 | |||||
| 166 | 634 | 99µs | my $gz = $self->[0] ; | ||
| 167 | 634 | 915µs | 634 | 16.1ms | if ($self->gzeof() || $len == 0) { # spent 16.1ms making 634 calls to Compress::Zlib::gzFile::gzeof, avg 25µs/call |
| 168 | # Zap the output buffer to match ver 1 behaviour. | ||||
| 169 | 2 | 0s | $_[0] = "" ; | ||
| 170 | 2 | 2µs | 2 | 142µs | _save_gzerr($gz, 1); # spent 142µs making 2 calls to Compress::Zlib::_save_gzerr, avg 71µs/call |
| 171 | 2 | 5µs | return 0 ; | ||
| 172 | } | ||||
| 173 | |||||
| 174 | 632 | 902µs | 632 | 122ms | my $status = $gz->read($_[0], $len) ; # spent 122ms making 632 calls to IO::Uncompress::Base::read, avg 193µs/call |
| 175 | 632 | 816µs | 632 | 18.0ms | _save_gzerr($gz, 1); # spent 18.0ms making 632 calls to Compress::Zlib::_save_gzerr, avg 29µs/call |
| 176 | 632 | 1.20ms | return $status ; | ||
| 177 | } | ||||
| 178 | |||||
| 179 | sub Compress::Zlib::gzFile::gzreadline | ||||
| 180 | { | ||||
| 181 | my $self = shift ; | ||||
| 182 | |||||
| 183 | my $gz = $self->[0] ; | ||||
| 184 | { | ||||
| 185 | # Maintain backward compatibility with 1.x behaviour | ||||
| 186 | # It didn't support $/, so this can't either. | ||||
| 187 | local $/ = "\n" ; | ||||
| 188 | $_[0] = $gz->getline() ; | ||||
| 189 | } | ||||
| 190 | _save_gzerr($gz, 1); | ||||
| 191 | return defined $_[0] ? length $_[0] : 0 ; | ||||
| 192 | } | ||||
| 193 | |||||
| 194 | sub Compress::Zlib::gzFile::gzwrite | ||||
| 195 | { | ||||
| 196 | my $self = shift ; | ||||
| 197 | my $gz = $self->[0] ; | ||||
| 198 | |||||
| 199 | return _set_gzerr(Z_STREAM_ERROR()) | ||||
| 200 | if $self->[1] ne 'deflate'; | ||||
| 201 | |||||
| 202 | $] >= 5.008 and (utf8::downgrade($_[0], 1) | ||||
| 203 | or croak "Wide character in gzwrite"); | ||||
| 204 | |||||
| 205 | my $status = $gz->write($_[0]) ; | ||||
| 206 | _save_gzerr($gz); | ||||
| 207 | return $status ; | ||||
| 208 | } | ||||
| 209 | |||||
| 210 | sub Compress::Zlib::gzFile::gztell | ||||
| 211 | { | ||||
| 212 | my $self = shift ; | ||||
| 213 | my $gz = $self->[0] ; | ||||
| 214 | my $status = $gz->tell() ; | ||||
| 215 | _save_gzerr($gz); | ||||
| 216 | return $status ; | ||||
| 217 | } | ||||
| 218 | |||||
| 219 | sub Compress::Zlib::gzFile::gzseek | ||||
| 220 | { | ||||
| 221 | my $self = shift ; | ||||
| 222 | my $offset = shift ; | ||||
| 223 | my $whence = shift ; | ||||
| 224 | |||||
| 225 | my $gz = $self->[0] ; | ||||
| 226 | my $status ; | ||||
| 227 | eval { $status = $gz->seek($offset, $whence) ; }; | ||||
| 228 | if ($@) | ||||
| 229 | { | ||||
| 230 | my $error = $@; | ||||
| 231 | $error =~ s/^.*: /gzseek: /; | ||||
| 232 | $error =~ s/ at .* line \d+\s*$//; | ||||
| 233 | croak $error; | ||||
| 234 | } | ||||
| 235 | _save_gzerr($gz); | ||||
| 236 | return $status ; | ||||
| 237 | } | ||||
| 238 | |||||
| 239 | sub Compress::Zlib::gzFile::gzflush | ||||
| 240 | { | ||||
| 241 | my $self = shift ; | ||||
| 242 | my $f = shift ; | ||||
| 243 | |||||
| 244 | my $gz = $self->[0] ; | ||||
| 245 | my $status = $gz->flush($f) ; | ||||
| 246 | my $err = _save_gzerr($gz); | ||||
| 247 | return $status ? 0 : $err; | ||||
| 248 | } | ||||
| 249 | |||||
| 250 | sub Compress::Zlib::gzFile::gzclose | ||||
| 251 | # spent 345µs (49+296) within Compress::Zlib::gzFile::gzclose which was called 3 times, avg 115µs/call:
# 2 times (33µs+200µs) by CPAN::Tarzip::gtest at line 157 of CPAN/Tarzip.pm, avg 116µs/call
# once (16µs+96µs) by CPAN::Tarzip::DESTROY at line 236 of CPAN/Tarzip.pm | ||||
| 252 | 3 | 2µs | my $self = shift ; | ||
| 253 | 3 | 0s | my $gz = $self->[0] ; | ||
| 254 | |||||
| 255 | 3 | 34µs | 3 | 247µs | my $status = $gz->close() ; # spent 247µs making 3 calls to IO::Uncompress::Base::close, avg 82µs/call |
| 256 | 3 | 7µs | 3 | 49µs | my $err = _save_gzerr($gz); # spent 49µs making 3 calls to Compress::Zlib::_save_gzerr, avg 16µs/call |
| 257 | 3 | 14µs | return $status ? 0 : $err; | ||
| 258 | } | ||||
| 259 | |||||
| 260 | sub Compress::Zlib::gzFile::gzeof | ||||
| 261 | # spent 16.1ms (3.87+12.3) within Compress::Zlib::gzFile::gzeof which was called 634 times, avg 25µs/call:
# 634 times (3.87ms+12.3ms) by Compress::Zlib::gzFile::gzread at line 167, avg 25µs/call | ||||
| 262 | 634 | 125µs | my $self = shift ; | ||
| 263 | 634 | 116µs | my $gz = $self->[0] ; | ||
| 264 | |||||
| 265 | 634 | 159µs | return 0 | ||
| 266 | if $self->[1] ne 'inflate'; | ||||
| 267 | |||||
| 268 | 634 | 790µs | 634 | 1.02ms | my $status = $gz->eof() ; # spent 1.02ms making 634 calls to IO::Uncompress::Base::eof, avg 2µs/call |
| 269 | 634 | 631µs | 634 | 11.3ms | _save_gzerr($gz); # spent 11.3ms making 634 calls to Compress::Zlib::_save_gzerr, avg 18µs/call |
| 270 | 634 | 1.26ms | return $status ; | ||
| 271 | } | ||||
| 272 | |||||
| 273 | sub Compress::Zlib::gzFile::gzsetparams | ||||
| 274 | { | ||||
| 275 | my $self = shift ; | ||||
| 276 | croak "Usage: Compress::Zlib::gzFile::gzsetparams(file, level, strategy)" | ||||
| 277 | unless @_ eq 2 ; | ||||
| 278 | |||||
| 279 | my $gz = $self->[0] ; | ||||
| 280 | my $level = shift ; | ||||
| 281 | my $strategy = shift; | ||||
| 282 | |||||
| 283 | return _set_gzerr(Z_STREAM_ERROR()) | ||||
| 284 | if $self->[1] ne 'deflate'; | ||||
| 285 | |||||
| 286 | my $status = *$gz->{Compress}->deflateParams(-Level => $level, | ||||
| 287 | -Strategy => $strategy); | ||||
| 288 | _save_gzerr($gz); | ||||
| 289 | return $status ; | ||||
| 290 | } | ||||
| 291 | |||||
| 292 | sub Compress::Zlib::gzFile::gzerror | ||||
| 293 | # spent 7µs within Compress::Zlib::gzFile::gzerror which was called 2 times, avg 4µs/call:
# 2 times (7µs+0s) by CPAN::Tarzip::gtest at line 151 of CPAN/Tarzip.pm, avg 4µs/call | ||||
| 294 | 2 | 0s | my $self = shift ; | ||
| 295 | 2 | 2µs | my $gz = $self->[0] ; | ||
| 296 | |||||
| 297 | 2 | 7µs | return $Compress::Zlib::gzerrno ; | ||
| 298 | } | ||||
| 299 | |||||
| 300 | |||||
| 301 | sub compress($;$) | ||||
| 302 | { | ||||
| 303 | my ($x, $output, $err, $in) =('', '', '', '') ; | ||||
| 304 | |||||
| 305 | if (ref $_[0] ) { | ||||
| 306 | $in = $_[0] ; | ||||
| 307 | croak "not a scalar reference" unless ref $in eq 'SCALAR' ; | ||||
| 308 | } | ||||
| 309 | else { | ||||
| 310 | $in = \$_[0] ; | ||||
| 311 | } | ||||
| 312 | |||||
| 313 | $] >= 5.008 and (utf8::downgrade($$in, 1) | ||||
| 314 | or croak "Wide character in compress"); | ||||
| 315 | |||||
| 316 | my $level = (@_ == 2 ? $_[1] : Z_DEFAULT_COMPRESSION() ); | ||||
| 317 | |||||
| 318 | $x = Compress::Raw::Zlib::_deflateInit(FLAG_APPEND, | ||||
| 319 | $level, | ||||
| 320 | Z_DEFLATED, | ||||
| 321 | MAX_WBITS, | ||||
| 322 | MAX_MEM_LEVEL, | ||||
| 323 | Z_DEFAULT_STRATEGY, | ||||
| 324 | 4096, | ||||
| 325 | '') | ||||
| 326 | or return undef ; | ||||
| 327 | |||||
| 328 | $err = $x->deflate($in, $output) ; | ||||
| 329 | return undef unless $err == Z_OK() ; | ||||
| 330 | |||||
| 331 | $err = $x->flush($output) ; | ||||
| 332 | return undef unless $err == Z_OK() ; | ||||
| 333 | |||||
| 334 | return $output ; | ||||
| 335 | } | ||||
| 336 | |||||
| 337 | sub uncompress($) | ||||
| 338 | { | ||||
| 339 | my ($output, $in) =('', '') ; | ||||
| 340 | |||||
| 341 | if (ref $_[0] ) { | ||||
| 342 | $in = $_[0] ; | ||||
| 343 | croak "not a scalar reference" unless ref $in eq 'SCALAR' ; | ||||
| 344 | } | ||||
| 345 | else { | ||||
| 346 | $in = \$_[0] ; | ||||
| 347 | } | ||||
| 348 | |||||
| 349 | $] >= 5.008 and (utf8::downgrade($$in, 1) | ||||
| 350 | or croak "Wide character in uncompress"); | ||||
| 351 | |||||
| 352 | my ($obj, $status) = Compress::Raw::Zlib::_inflateInit(0, | ||||
| 353 | MAX_WBITS, 4096, "") ; | ||||
| 354 | |||||
| 355 | $status == Z_OK | ||||
| 356 | or return undef; | ||||
| 357 | |||||
| 358 | $obj->inflate($in, $output) == Z_STREAM_END | ||||
| 359 | or return undef; | ||||
| 360 | |||||
| 361 | return $output; | ||||
| 362 | } | ||||
| 363 | |||||
| 364 | sub deflateInit(@) | ||||
| 365 | { | ||||
| 366 | my ($got) = ParseParameters(0, | ||||
| 367 | { | ||||
| 368 | 'bufsize' => [IO::Compress::Base::Common::Parse_unsigned, 4096], | ||||
| 369 | 'level' => [IO::Compress::Base::Common::Parse_signed, Z_DEFAULT_COMPRESSION()], | ||||
| 370 | 'method' => [IO::Compress::Base::Common::Parse_unsigned, Z_DEFLATED()], | ||||
| 371 | 'windowbits' => [IO::Compress::Base::Common::Parse_signed, MAX_WBITS()], | ||||
| 372 | 'memlevel' => [IO::Compress::Base::Common::Parse_unsigned, MAX_MEM_LEVEL()], | ||||
| 373 | 'strategy' => [IO::Compress::Base::Common::Parse_unsigned, Z_DEFAULT_STRATEGY()], | ||||
| 374 | 'dictionary' => [IO::Compress::Base::Common::Parse_any, ""], | ||||
| 375 | }, @_ ) ; | ||||
| 376 | |||||
| 377 | croak "Compress::Zlib::deflateInit: Bufsize must be >= 1, you specified " . | ||||
| 378 | $got->getValue('bufsize') | ||||
| 379 | unless $got->getValue('bufsize') >= 1; | ||||
| 380 | |||||
| 381 | my $obj ; | ||||
| 382 | |||||
| 383 | my $status = 0 ; | ||||
| 384 | ($obj, $status) = | ||||
| 385 | Compress::Raw::Zlib::_deflateInit(0, | ||||
| 386 | $got->getValue('level'), | ||||
| 387 | $got->getValue('method'), | ||||
| 388 | $got->getValue('windowbits'), | ||||
| 389 | $got->getValue('memlevel'), | ||||
| 390 | $got->getValue('strategy'), | ||||
| 391 | $got->getValue('bufsize'), | ||||
| 392 | $got->getValue('dictionary')) ; | ||||
| 393 | |||||
| 394 | my $x = ($status == Z_OK() ? bless $obj, "Zlib::OldDeflate" : undef) ; | ||||
| 395 | return wantarray ? ($x, $status) : $x ; | ||||
| 396 | } | ||||
| 397 | |||||
| 398 | sub inflateInit(@) | ||||
| 399 | { | ||||
| 400 | my ($got) = ParseParameters(0, | ||||
| 401 | { | ||||
| 402 | 'bufsize' => [IO::Compress::Base::Common::Parse_unsigned, 4096], | ||||
| 403 | 'windowbits' => [IO::Compress::Base::Common::Parse_signed, MAX_WBITS()], | ||||
| 404 | 'dictionary' => [IO::Compress::Base::Common::Parse_any, ""], | ||||
| 405 | }, @_) ; | ||||
| 406 | |||||
| 407 | |||||
| 408 | croak "Compress::Zlib::inflateInit: Bufsize must be >= 1, you specified " . | ||||
| 409 | $got->getValue('bufsize') | ||||
| 410 | unless $got->getValue('bufsize') >= 1; | ||||
| 411 | |||||
| 412 | my $status = 0 ; | ||||
| 413 | my $obj ; | ||||
| 414 | ($obj, $status) = Compress::Raw::Zlib::_inflateInit(FLAG_CONSUME_INPUT, | ||||
| 415 | $got->getValue('windowbits'), | ||||
| 416 | $got->getValue('bufsize'), | ||||
| 417 | $got->getValue('dictionary')) ; | ||||
| 418 | |||||
| 419 | my $x = ($status == Z_OK() ? bless $obj, "Zlib::OldInflate" : undef) ; | ||||
| 420 | |||||
| 421 | wantarray ? ($x, $status) : $x ; | ||||
| 422 | } | ||||
| 423 | |||||
| 424 | package Zlib::OldDeflate ; | ||||
| 425 | |||||
| 426 | our (@ISA); | ||||
| 427 | 1 | 8µs | @ISA = qw(Compress::Raw::Zlib::deflateStream); | ||
| 428 | |||||
| 429 | |||||
| 430 | sub deflate | ||||
| 431 | { | ||||
| 432 | my $self = shift ; | ||||
| 433 | my $output ; | ||||
| 434 | |||||
| 435 | my $status = $self->SUPER::deflate($_[0], $output) ; | ||||
| 436 | wantarray ? ($output, $status) : $output ; | ||||
| 437 | } | ||||
| 438 | |||||
| 439 | sub flush | ||||
| 440 | { | ||||
| 441 | my $self = shift ; | ||||
| 442 | my $output ; | ||||
| 443 | my $flag = shift || Compress::Zlib::Z_FINISH(); | ||||
| 444 | my $status = $self->SUPER::flush($output, $flag) ; | ||||
| 445 | |||||
| 446 | wantarray ? ($output, $status) : $output ; | ||||
| 447 | } | ||||
| 448 | |||||
| 449 | package Zlib::OldInflate ; | ||||
| 450 | |||||
| 451 | our (@ISA); | ||||
| 452 | 1 | 7µs | @ISA = qw(Compress::Raw::Zlib::inflateStream); | ||
| 453 | |||||
| 454 | sub inflate | ||||
| 455 | { | ||||
| 456 | my $self = shift ; | ||||
| 457 | my $output ; | ||||
| 458 | my $status = $self->SUPER::inflate($_[0], $output) ; | ||||
| 459 | wantarray ? ($output, $status) : $output ; | ||||
| 460 | } | ||||
| 461 | |||||
| 462 | package Compress::Zlib ; | ||||
| 463 | |||||
| 464 | 3 | 869µs | 3 | 567µs | # spent 295µs (23+272) within Compress::Zlib::BEGIN@464 which was called:
# once (23µs+272µs) by CPAN::has_inst at line 464 # spent 295µs making 1 call to Compress::Zlib::BEGIN@464
# spent 260µs making 1 call to Exporter::import
# spent 12µs making 1 call to version::_VERSION |
| 465 | |||||
| 466 | sub memGzip($) | ||||
| 467 | { | ||||
| 468 | _set_gzerr(0); | ||||
| 469 | my $x = Compress::Raw::Zlib::_deflateInit(FLAG_APPEND|FLAG_CRC, | ||||
| 470 | Z_BEST_COMPRESSION, | ||||
| 471 | Z_DEFLATED, | ||||
| 472 | -MAX_WBITS(), | ||||
| 473 | MAX_MEM_LEVEL, | ||||
| 474 | Z_DEFAULT_STRATEGY, | ||||
| 475 | 4096, | ||||
| 476 | '') | ||||
| 477 | or return undef ; | ||||
| 478 | |||||
| 479 | # if the deflation buffer isn't a reference, make it one | ||||
| 480 | my $string = (ref $_[0] ? $_[0] : \$_[0]) ; | ||||
| 481 | |||||
| 482 | $] >= 5.008 and (utf8::downgrade($$string, 1) | ||||
| 483 | or croak "Wide character in memGzip"); | ||||
| 484 | |||||
| 485 | my $out; | ||||
| 486 | my $status ; | ||||
| 487 | |||||
| 488 | $x->deflate($string, $out) == Z_OK | ||||
| 489 | or return undef ; | ||||
| 490 | |||||
| 491 | $x->flush($out) == Z_OK | ||||
| 492 | or return undef ; | ||||
| 493 | |||||
| 494 | return IO::Compress::Gzip::Constants::GZIP_MINIMUM_HEADER . | ||||
| 495 | $out . | ||||
| 496 | pack("V V", $x->crc32(), $x->total_in()); | ||||
| 497 | } | ||||
| 498 | |||||
| 499 | |||||
| 500 | sub _removeGzipHeader($) | ||||
| 501 | { | ||||
| 502 | my $string = shift ; | ||||
| 503 | |||||
| 504 | return Z_DATA_ERROR() | ||||
| 505 | if length($$string) < GZIP_MIN_HEADER_SIZE ; | ||||
| 506 | |||||
| 507 | my ($magic1, $magic2, $method, $flags, $time, $xflags, $oscode) = | ||||
| 508 | unpack ('CCCCVCC', $$string); | ||||
| 509 | |||||
| 510 | return Z_DATA_ERROR() | ||||
| 511 | unless $magic1 == GZIP_ID1 and $magic2 == GZIP_ID2 and | ||||
| 512 | $method == Z_DEFLATED() and !($flags & GZIP_FLG_RESERVED) ; | ||||
| 513 | substr($$string, 0, GZIP_MIN_HEADER_SIZE) = '' ; | ||||
| 514 | |||||
| 515 | # skip extra field | ||||
| 516 | if ($flags & GZIP_FLG_FEXTRA) | ||||
| 517 | { | ||||
| 518 | return Z_DATA_ERROR() | ||||
| 519 | if length($$string) < GZIP_FEXTRA_HEADER_SIZE ; | ||||
| 520 | |||||
| 521 | my ($extra_len) = unpack ('v', $$string); | ||||
| 522 | $extra_len += GZIP_FEXTRA_HEADER_SIZE; | ||||
| 523 | return Z_DATA_ERROR() | ||||
| 524 | if length($$string) < $extra_len ; | ||||
| 525 | |||||
| 526 | substr($$string, 0, $extra_len) = ''; | ||||
| 527 | } | ||||
| 528 | |||||
| 529 | # skip orig name | ||||
| 530 | if ($flags & GZIP_FLG_FNAME) | ||||
| 531 | { | ||||
| 532 | my $name_end = index ($$string, GZIP_NULL_BYTE); | ||||
| 533 | return Z_DATA_ERROR() | ||||
| 534 | if $name_end == -1 ; | ||||
| 535 | substr($$string, 0, $name_end + 1) = ''; | ||||
| 536 | } | ||||
| 537 | |||||
| 538 | # skip comment | ||||
| 539 | if ($flags & GZIP_FLG_FCOMMENT) | ||||
| 540 | { | ||||
| 541 | my $comment_end = index ($$string, GZIP_NULL_BYTE); | ||||
| 542 | return Z_DATA_ERROR() | ||||
| 543 | if $comment_end == -1 ; | ||||
| 544 | substr($$string, 0, $comment_end + 1) = ''; | ||||
| 545 | } | ||||
| 546 | |||||
| 547 | # skip header crc | ||||
| 548 | if ($flags & GZIP_FLG_FHCRC) | ||||
| 549 | { | ||||
| 550 | return Z_DATA_ERROR() | ||||
| 551 | if length ($$string) < GZIP_FHCRC_SIZE ; | ||||
| 552 | substr($$string, 0, GZIP_FHCRC_SIZE) = ''; | ||||
| 553 | } | ||||
| 554 | |||||
| 555 | return Z_OK(); | ||||
| 556 | } | ||||
| 557 | |||||
| 558 | sub _ret_gun_error | ||||
| 559 | { | ||||
| 560 | $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError; | ||||
| 561 | return undef; | ||||
| 562 | } | ||||
| 563 | |||||
| 564 | |||||
| 565 | sub memGunzip($) | ||||
| 566 | { | ||||
| 567 | # if the buffer isn't a reference, make it one | ||||
| 568 | my $string = (ref $_[0] ? $_[0] : \$_[0]); | ||||
| 569 | |||||
| 570 | $] >= 5.008 and (utf8::downgrade($$string, 1) | ||||
| 571 | or croak "Wide character in memGunzip"); | ||||
| 572 | |||||
| 573 | _set_gzerr(0); | ||||
| 574 | |||||
| 575 | my $status = _removeGzipHeader($string) ; | ||||
| 576 | $status == Z_OK() | ||||
| 577 | or return _set_gzerr_undef($status); | ||||
| 578 | |||||
| 579 | my $bufsize = length $$string > 4096 ? length $$string : 4096 ; | ||||
| 580 | my $x = Compress::Raw::Zlib::_inflateInit(FLAG_CRC | FLAG_CONSUME_INPUT, | ||||
| 581 | -MAX_WBITS(), $bufsize, '') | ||||
| 582 | or return _ret_gun_error(); | ||||
| 583 | |||||
| 584 | my $output = '' ; | ||||
| 585 | $status = $x->inflate($string, $output); | ||||
| 586 | |||||
| 587 | if ( $status == Z_OK() ) | ||||
| 588 | { | ||||
| 589 | _set_gzerr(Z_DATA_ERROR()); | ||||
| 590 | return undef; | ||||
| 591 | } | ||||
| 592 | |||||
| 593 | return _ret_gun_error() | ||||
| 594 | if ($status != Z_STREAM_END()); | ||||
| 595 | |||||
| 596 | if (length $$string >= 8) | ||||
| 597 | { | ||||
| 598 | my ($crc, $len) = unpack ("VV", substr($$string, 0, 8)); | ||||
| 599 | substr($$string, 0, 8) = ''; | ||||
| 600 | return _set_gzerr_undef(Z_DATA_ERROR()) | ||||
| 601 | unless $len == length($output) and | ||||
| 602 | $crc == Compress::Raw::Zlib::crc32($output); | ||||
| 603 | } | ||||
| 604 | else | ||||
| 605 | { | ||||
| 606 | $$string = ''; | ||||
| 607 | } | ||||
| 608 | |||||
| 609 | return $output; | ||||
| 610 | } | ||||
| 611 | |||||
| 612 | # Autoload methods go after __END__, and are processed by the autosplit program. | ||||
| 613 | |||||
| 614 | 1 | 12µs | 1; | ||
| 615 | __END__ | ||||
# spent 37µs within Compress::Zlib::CORE:match which was called 21 times, avg 2µs/call:
# 3 times (14µs+0s) by Compress::Zlib::gzopen at line 117, avg 5µs/call
# 3 times (8µs+0s) by Compress::Zlib::gzopen at line 132, avg 3µs/call
# 3 times (5µs+0s) by Compress::Zlib::gzopen at line 118, avg 2µs/call
# 3 times (4µs+0s) by Compress::Zlib::gzopen at line 120, avg 1µs/call
# 3 times (2µs+0s) by Compress::Zlib::gzopen at line 123, avg 667ns/call
# 3 times (2µs+0s) by Compress::Zlib::gzopen at line 122, avg 667ns/call
# 3 times (2µs+0s) by Compress::Zlib::gzopen at line 121, avg 667ns/call |