| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/5.22.0/IO/Compress/Gzip.pm |
| Statements | Executed 32 statements in 948µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 548µs | 1.22ms | IO::Compress::Gzip::BEGIN@15 |
| 1 | 1 | 1 | 520µs | 689µs | IO::Compress::Gzip::BEGIN@16 |
| 1 | 1 | 1 | 9µs | 121µs | IO::Compress::Gzip::BEGIN@12 |
| 1 | 1 | 1 | 9µs | 11µs | IO::Compress::Gzip::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 14µs | IO::Compress::Gzip::BEGIN@11 |
| 1 | 1 | 1 | 7µs | 78µs | IO::Compress::Gzip::BEGIN@14 |
| 1 | 1 | 1 | 6µs | 8µs | IO::Compress::Gzip::BEGIN@7 |
| 1 | 1 | 1 | 4µs | 8µs | IO::Compress::Gzip::BEGIN@6 |
| 1 | 1 | 1 | 3µs | 3µs | IO::Compress::Gzip::BEGIN@19 |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::__ANON__[:23] |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::ckParams |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::getExtraParams |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::getFileInfo |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::getInverseClass |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::gzip |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::mkFinalTrailer |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::mkHeader |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::mkTrailer |
| 0 | 0 | 0 | 0s | 0s | IO::Compress::Gzip::new |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package IO::Compress::Gzip ; | ||||
| 2 | |||||
| 3 | 1 | 5µs | require 5.006 ; | ||
| 4 | |||||
| 5 | 2 | 14µs | 2 | 12µs | # spent 11µs (9+1) within IO::Compress::Gzip::BEGIN@5 which was called:
# once (9µs+1µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 5 # spent 11µs making 1 call to IO::Compress::Gzip::BEGIN@5
# spent 1µs making 1 call to strict::import |
| 6 | 2 | 12µs | 2 | 11µs | # spent 8µs (4+4) within IO::Compress::Gzip::BEGIN@6 which was called:
# once (4µs+4µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 6 # spent 8µs making 1 call to IO::Compress::Gzip::BEGIN@6
# spent 4µs making 1 call to warnings::import |
| 7 | 2 | 20µs | 2 | 9µs | # spent 8µs (6+2) within IO::Compress::Gzip::BEGIN@7 which was called:
# once (6µs+2µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 7 # spent 8µs making 1 call to IO::Compress::Gzip::BEGIN@7
# spent 2µs making 1 call to bytes::import |
| 8 | |||||
| 9 | 1 | 300ns | require Exporter ; | ||
| 10 | |||||
| 11 | 3 | 27µs | 2 | 22µs | # spent 14µs (7+7) within IO::Compress::Gzip::BEGIN@11 which was called:
# once (7µs+7µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 11 # spent 14µs making 1 call to IO::Compress::Gzip::BEGIN@11
# spent 7µs making 1 call to UNIVERSAL::VERSION |
| 12 | 3 | 27µs | 3 | 233µs | # spent 121µs (9+112) within IO::Compress::Gzip::BEGIN@12 which was called:
# once (9µs+112µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 12 # spent 121µs making 1 call to IO::Compress::Gzip::BEGIN@12
# spent 108µs making 1 call to Exporter::import
# spent 3µs making 1 call to UNIVERSAL::VERSION |
| 13 | |||||
| 14 | 3 | 36µs | 3 | 150µs | # spent 78µs (7+71) within IO::Compress::Gzip::BEGIN@14 which was called:
# once (7µs+71µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 14 # spent 78µs making 1 call to IO::Compress::Gzip::BEGIN@14
# spent 68µs making 1 call to Exporter::import
# spent 4µs making 1 call to UNIVERSAL::VERSION |
| 15 | 3 | 76µs | 3 | 1.34ms | # spent 1.22ms (548µs+670µs) within IO::Compress::Gzip::BEGIN@15 which was called:
# once (548µs+670µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 15 # spent 1.22ms making 1 call to IO::Compress::Gzip::BEGIN@15
# spent 114µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
| 16 | 3 | 90µs | 2 | 692µs | # spent 689µs (520+169) within IO::Compress::Gzip::BEGIN@16 which was called:
# once (520µs+169µs) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 16 # spent 689µs making 1 call to IO::Compress::Gzip::BEGIN@16
# spent 4µs making 1 call to UNIVERSAL::VERSION |
| 17 | |||||
| 18 | BEGIN | ||||
| 19 | # spent 3µs within IO::Compress::Gzip::BEGIN@19 which was called:
# once (3µs+0s) by Search::Elasticsearch::Role::Cxn::BEGIN@10 at line 24 | ||||
| 20 | 1 | 3µs | if (defined &utf8::downgrade ) | ||
| 21 | { *noUTF8 = \&utf8::downgrade } | ||||
| 22 | else | ||||
| 23 | { *noUTF8 = sub {} } | ||||
| 24 | 1 | 617µs | 1 | 3µs | } # spent 3µs making 1 call to IO::Compress::Gzip::BEGIN@19 |
| 25 | |||||
| 26 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $GzipError); | ||||
| 27 | |||||
| 28 | 1 | 300ns | $VERSION = '2.068'; | ||
| 29 | 1 | 100ns | $GzipError = '' ; | ||
| 30 | |||||
| 31 | 1 | 7µs | @ISA = qw(Exporter IO::Compress::RawDeflate); | ||
| 32 | 1 | 400ns | @EXPORT_OK = qw( $GzipError gzip ) ; | ||
| 33 | 1 | 4µs | %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ; | ||
| 34 | |||||
| 35 | 1 | 900ns | push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; | ||
| 36 | 1 | 2µs | 1 | 11µs | Exporter::export_ok_tags('all'); # spent 11µs making 1 call to Exporter::export_ok_tags |
| 37 | |||||
| 38 | sub new | ||||
| 39 | { | ||||
| 40 | my $class = shift ; | ||||
| 41 | |||||
| 42 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$GzipError); | ||||
| 43 | |||||
| 44 | $obj->_create(undef, @_); | ||||
| 45 | } | ||||
| 46 | |||||
| 47 | |||||
| 48 | sub gzip | ||||
| 49 | { | ||||
| 50 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$GzipError); | ||||
| 51 | return $obj->_def(@_); | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | #sub newHeader | ||||
| 55 | #{ | ||||
| 56 | # my $self = shift ; | ||||
| 57 | # #return GZIP_MINIMUM_HEADER ; | ||||
| 58 | # return $self->mkHeader(*$self->{Got}); | ||||
| 59 | #} | ||||
| 60 | |||||
| 61 | sub getExtraParams | ||||
| 62 | { | ||||
| 63 | my $self = shift ; | ||||
| 64 | |||||
| 65 | return ( | ||||
| 66 | # zlib behaviour | ||||
| 67 | $self->getZlibParams(), | ||||
| 68 | |||||
| 69 | # Gzip header fields | ||||
| 70 | 'minimal' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
| 71 | 'comment' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 72 | 'name' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 73 | 'time' => [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 74 | 'textflag' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
| 75 | 'headercrc' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||
| 76 | 'os_code' => [IO::Compress::Base::Common::Parse_unsigned, $Compress::Raw::Zlib::gzip_os_code], | ||||
| 77 | 'extrafield'=> [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 78 | 'extraflags'=> [IO::Compress::Base::Common::Parse_any, undef], | ||||
| 79 | |||||
| 80 | ); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | |||||
| 84 | sub ckParams | ||||
| 85 | { | ||||
| 86 | my $self = shift ; | ||||
| 87 | my $got = shift ; | ||||
| 88 | |||||
| 89 | # gzip always needs crc32 | ||||
| 90 | $got->setValue('crc32' => 1); | ||||
| 91 | |||||
| 92 | return 1 | ||||
| 93 | if $got->getValue('merge') ; | ||||
| 94 | |||||
| 95 | my $strict = $got->getValue('strict') ; | ||||
| 96 | |||||
| 97 | |||||
| 98 | { | ||||
| 99 | if (! $got->parsed('time') ) { | ||||
| 100 | # Modification time defaults to now. | ||||
| 101 | $got->setValue(time => time) ; | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | # Check that the Name & Comment don't have embedded NULLs | ||||
| 105 | # Also check that they only contain ISO 8859-1 chars. | ||||
| 106 | if ($got->parsed('name') && defined $got->getValue('name')) { | ||||
| 107 | my $name = $got->getValue('name'); | ||||
| 108 | |||||
| 109 | return $self->saveErrorString(undef, "Null Character found in Name", | ||||
| 110 | Z_DATA_ERROR) | ||||
| 111 | if $strict && $name =~ /\x00/ ; | ||||
| 112 | |||||
| 113 | return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Name", | ||||
| 114 | Z_DATA_ERROR) | ||||
| 115 | if $strict && $name =~ /$GZIP_FNAME_INVALID_CHAR_RE/o ; | ||||
| 116 | } | ||||
| 117 | |||||
| 118 | if ($got->parsed('comment') && defined $got->getValue('comment')) { | ||||
| 119 | my $comment = $got->getValue('comment'); | ||||
| 120 | |||||
| 121 | return $self->saveErrorString(undef, "Null Character found in Comment", | ||||
| 122 | Z_DATA_ERROR) | ||||
| 123 | if $strict && $comment =~ /\x00/ ; | ||||
| 124 | |||||
| 125 | return $self->saveErrorString(undef, "Non ISO 8859-1 Character found in Comment", | ||||
| 126 | Z_DATA_ERROR) | ||||
| 127 | if $strict && $comment =~ /$GZIP_FCOMMENT_INVALID_CHAR_RE/o; | ||||
| 128 | } | ||||
| 129 | |||||
| 130 | if ($got->parsed('os_code') ) { | ||||
| 131 | my $value = $got->getValue('os_code'); | ||||
| 132 | |||||
| 133 | return $self->saveErrorString(undef, "OS_Code must be between 0 and 255, got '$value'") | ||||
| 134 | if $value < 0 || $value > 255 ; | ||||
| 135 | |||||
| 136 | } | ||||
| 137 | |||||
| 138 | # gzip only supports Deflate at present | ||||
| 139 | $got->setValue('method' => Z_DEFLATED) ; | ||||
| 140 | |||||
| 141 | if ( ! $got->parsed('extraflags')) { | ||||
| 142 | $got->setValue('extraflags' => 2) | ||||
| 143 | if $got->getValue('level') == Z_BEST_COMPRESSION ; | ||||
| 144 | $got->setValue('extraflags' => 4) | ||||
| 145 | if $got->getValue('level') == Z_BEST_SPEED ; | ||||
| 146 | } | ||||
| 147 | |||||
| 148 | my $data = $got->getValue('extrafield') ; | ||||
| 149 | if (defined $data) { | ||||
| 150 | my $bad = IO::Compress::Zlib::Extra::parseExtraField($data, $strict, 1) ; | ||||
| 151 | return $self->saveErrorString(undef, "Error with ExtraField Parameter: $bad", Z_DATA_ERROR) | ||||
| 152 | if $bad ; | ||||
| 153 | |||||
| 154 | $got->setValue('extrafield' => $data) ; | ||||
| 155 | } | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | return 1; | ||||
| 159 | } | ||||
| 160 | |||||
| 161 | sub mkTrailer | ||||
| 162 | { | ||||
| 163 | my $self = shift ; | ||||
| 164 | return pack("V V", *$self->{Compress}->crc32(), | ||||
| 165 | *$self->{UnCompSize}->get32bit()); | ||||
| 166 | } | ||||
| 167 | |||||
| 168 | sub getInverseClass | ||||
| 169 | { | ||||
| 170 | return ('IO::Uncompress::Gunzip', | ||||
| 171 | \$IO::Uncompress::Gunzip::GunzipError); | ||||
| 172 | } | ||||
| 173 | |||||
| 174 | sub getFileInfo | ||||
| 175 | { | ||||
| 176 | my $self = shift ; | ||||
| 177 | my $params = shift; | ||||
| 178 | my $filename = shift ; | ||||
| 179 | |||||
| 180 | return if IO::Compress::Base::Common::isaScalar($filename); | ||||
| 181 | |||||
| 182 | my $defaultTime = (stat($filename))[9] ; | ||||
| 183 | |||||
| 184 | $params->setValue('name' => $filename) | ||||
| 185 | if ! $params->parsed('name') ; | ||||
| 186 | |||||
| 187 | $params->setValue('time' => $defaultTime) | ||||
| 188 | if ! $params->parsed('time') ; | ||||
| 189 | } | ||||
| 190 | |||||
| 191 | |||||
| 192 | sub mkHeader | ||||
| 193 | { | ||||
| 194 | my $self = shift ; | ||||
| 195 | my $param = shift ; | ||||
| 196 | |||||
| 197 | # short-circuit if a minimal header is requested. | ||||
| 198 | return GZIP_MINIMUM_HEADER if $param->getValue('minimal') ; | ||||
| 199 | |||||
| 200 | # METHOD | ||||
| 201 | my $method = $param->valueOrDefault('method', GZIP_CM_DEFLATED) ; | ||||
| 202 | |||||
| 203 | # FLAGS | ||||
| 204 | my $flags = GZIP_FLG_DEFAULT ; | ||||
| 205 | $flags |= GZIP_FLG_FTEXT if $param->getValue('textflag') ; | ||||
| 206 | $flags |= GZIP_FLG_FHCRC if $param->getValue('headercrc') ; | ||||
| 207 | $flags |= GZIP_FLG_FEXTRA if $param->wantValue('extrafield') ; | ||||
| 208 | $flags |= GZIP_FLG_FNAME if $param->wantValue('name') ; | ||||
| 209 | $flags |= GZIP_FLG_FCOMMENT if $param->wantValue('comment') ; | ||||
| 210 | |||||
| 211 | # MTIME | ||||
| 212 | my $time = $param->valueOrDefault('time', GZIP_MTIME_DEFAULT) ; | ||||
| 213 | |||||
| 214 | # EXTRA FLAGS | ||||
| 215 | my $extra_flags = $param->valueOrDefault('extraflags', GZIP_XFL_DEFAULT); | ||||
| 216 | |||||
| 217 | # OS CODE | ||||
| 218 | my $os_code = $param->valueOrDefault('os_code', GZIP_OS_DEFAULT) ; | ||||
| 219 | |||||
| 220 | |||||
| 221 | my $out = pack("C4 V C C", | ||||
| 222 | GZIP_ID1, # ID1 | ||||
| 223 | GZIP_ID2, # ID2 | ||||
| 224 | $method, # Compression Method | ||||
| 225 | $flags, # Flags | ||||
| 226 | $time, # Modification Time | ||||
| 227 | $extra_flags, # Extra Flags | ||||
| 228 | $os_code, # Operating System Code | ||||
| 229 | ) ; | ||||
| 230 | |||||
| 231 | # EXTRA | ||||
| 232 | if ($flags & GZIP_FLG_FEXTRA) { | ||||
| 233 | my $extra = $param->getValue('extrafield') ; | ||||
| 234 | $out .= pack("v", length $extra) . $extra ; | ||||
| 235 | } | ||||
| 236 | |||||
| 237 | # NAME | ||||
| 238 | if ($flags & GZIP_FLG_FNAME) { | ||||
| 239 | my $name .= $param->getValue('name') ; | ||||
| 240 | $name =~ s/\x00.*$//; | ||||
| 241 | $out .= $name ; | ||||
| 242 | # Terminate the filename with NULL unless it already is | ||||
| 243 | $out .= GZIP_NULL_BYTE | ||||
| 244 | if !length $name or | ||||
| 245 | substr($name, 1, -1) ne GZIP_NULL_BYTE ; | ||||
| 246 | } | ||||
| 247 | |||||
| 248 | # COMMENT | ||||
| 249 | if ($flags & GZIP_FLG_FCOMMENT) { | ||||
| 250 | my $comment .= $param->getValue('comment') ; | ||||
| 251 | $comment =~ s/\x00.*$//; | ||||
| 252 | $out .= $comment ; | ||||
| 253 | # Terminate the comment with NULL unless it already is | ||||
| 254 | $out .= GZIP_NULL_BYTE | ||||
| 255 | if ! length $comment or | ||||
| 256 | substr($comment, 1, -1) ne GZIP_NULL_BYTE; | ||||
| 257 | } | ||||
| 258 | |||||
| 259 | # HEADER CRC | ||||
| 260 | $out .= pack("v", Compress::Raw::Zlib::crc32($out) & 0x00FF ) | ||||
| 261 | if $param->getValue('headercrc') ; | ||||
| 262 | |||||
| 263 | noUTF8($out); | ||||
| 264 | |||||
| 265 | return $out ; | ||||
| 266 | } | ||||
| 267 | |||||
| 268 | sub mkFinalTrailer | ||||
| 269 | { | ||||
| 270 | return ''; | ||||
| 271 | } | ||||
| 272 | |||||
| 273 | 1 | 5µs | 1; | ||
| 274 | |||||
| 275 | __END__ |