| Filename | /usr/lib/x86_64-linux-gnu/perl/5.28/Storable.pm |
| Statements | Executed 31 statements in 2.39ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 378µs | 2.53ms | Storable::BEGIN@72 |
| 1 | 1 | 1 | 60µs | 60µs | Storable::BEGIN@40 |
| 1 | 1 | 1 | 15µs | 18µs | Storable::BEGIN@478 |
| 1 | 1 | 1 | 3µs | 3µs | Storable::CORE:qr (opcode) |
| 0 | 0 | 0 | 0s | 0s | Storable::BIN_VERSION_NV |
| 0 | 0 | 0 | 0s | 0s | Storable::BIN_WRITE_VERSION_NV |
| 0 | 0 | 0 | 0s | 0s | Storable::CAN_FLOCK |
| 0 | 0 | 0 | 0s | 0s | Storable::CLONE |
| 0 | 0 | 0 | 0s | 0s | Storable::__ANON__[:58] |
| 0 | 0 | 0 | 0s | 0s | Storable::__ANON__[:64] |
| 0 | 0 | 0 | 0s | 0s | Storable::_freeze |
| 0 | 0 | 0 | 0s | 0s | Storable::_make_re |
| 0 | 0 | 0 | 0s | 0s | Storable::_retrieve |
| 0 | 0 | 0 | 0s | 0s | Storable::_store |
| 0 | 0 | 0 | 0s | 0s | Storable::_store_fd |
| 0 | 0 | 0 | 0s | 0s | Storable::fd_retrieve |
| 0 | 0 | 0 | 0s | 0s | Storable::file_magic |
| 0 | 0 | 0 | 0s | 0s | Storable::freeze |
| 0 | 0 | 0 | 0s | 0s | Storable::lock_nstore |
| 0 | 0 | 0 | 0s | 0s | Storable::lock_retrieve |
| 0 | 0 | 0 | 0s | 0s | Storable::lock_store |
| 0 | 0 | 0 | 0s | 0s | Storable::nfreeze |
| 0 | 0 | 0 | 0s | 0s | Storable::nstore |
| 0 | 0 | 0 | 0s | 0s | Storable::nstore_fd |
| 0 | 0 | 0 | 0s | 0s | Storable::read_magic |
| 0 | 0 | 0 | 0s | 0s | Storable::retrieve |
| 0 | 0 | 0 | 0s | 0s | Storable::retrieve_fd |
| 0 | 0 | 0 | 0s | 0s | Storable::show_file_magic |
| 0 | 0 | 0 | 0s | 0s | Storable::store |
| 0 | 0 | 0 | 0s | 0s | Storable::store_fd |
| 0 | 0 | 0 | 0s | 0s | Storable::thaw |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # | ||||
| 2 | # Copyright (c) 1995-2001, Raphael Manfredi | ||||
| 3 | # Copyright (c) 2002-2014 by the Perl 5 Porters | ||||
| 4 | # Copyright (c) 2015-2016 cPanel Inc | ||||
| 5 | # Copyright (c) 2017 Reini Urban | ||||
| 6 | # | ||||
| 7 | # You may redistribute only under the same terms as Perl 5, as specified | ||||
| 8 | # in the README file that comes with the distribution. | ||||
| 9 | # | ||||
| 10 | |||||
| 11 | 1 | 500ns | require XSLoader; | ||
| 12 | 1 | 200ns | require Exporter; | ||
| 13 | package Storable; | ||||
| 14 | |||||
| 15 | 1 | 8µs | our @ISA = qw(Exporter); | ||
| 16 | 1 | 700ns | our @EXPORT = qw(store retrieve); | ||
| 17 | 1 | 4µs | our @EXPORT_OK = qw( | ||
| 18 | nstore store_fd nstore_fd fd_retrieve | ||||
| 19 | freeze nfreeze thaw | ||||
| 20 | dclone | ||||
| 21 | retrieve_fd | ||||
| 22 | lock_store lock_nstore lock_retrieve | ||||
| 23 | file_magic read_magic | ||||
| 24 | BLESS_OK TIE_OK FLAGS_COMPAT | ||||
| 25 | stack_depth stack_depth_hash | ||||
| 26 | ); | ||||
| 27 | |||||
| 28 | our ($canonical, $forgive_me); | ||||
| 29 | |||||
| 30 | 1 | 200ns | our $VERSION = '3.08'; | ||
| 31 | |||||
| 32 | our $recursion_limit; | ||||
| 33 | our $recursion_limit_hash; | ||||
| 34 | |||||
| 35 | 1 | 300ns | $recursion_limit = 512 | ||
| 36 | unless defined $recursion_limit; | ||||
| 37 | 1 | 200ns | $recursion_limit_hash = 256 | ||
| 38 | unless defined $recursion_limit_hash; | ||||
| 39 | |||||
| 40 | # spent 60µs within Storable::BEGIN@40 which was called:
# once (60µs+0s) by Encode::BEGIN@55 at line 66 | ||||
| 41 | 1 | 200ns | if (eval { | ||
| 42 | 1 | 2µs | local $SIG{__DIE__}; | ||
| 43 | 1 | 2µs | local @INC = @INC; | ||
| 44 | 1 | 400ns | pop @INC if $INC[-1] eq '.'; | ||
| 45 | 1 | 42µs | require Log::Agent; | ||
| 46 | 1; | ||||
| 47 | }) { | ||||
| 48 | Log::Agent->import; | ||||
| 49 | } | ||||
| 50 | # | ||||
| 51 | # Use of Log::Agent is optional. If it hasn't imported these subs then | ||||
| 52 | # provide a fallback implementation. | ||||
| 53 | # | ||||
| 54 | 1 | 1µs | unless ($Storable::{logcroak} && *{$Storable::{logcroak}}{CODE}) { | ||
| 55 | 1 | 500ns | require Carp; | ||
| 56 | *logcroak = sub { | ||||
| 57 | Carp::croak(@_); | ||||
| 58 | 1 | 3µs | }; | ||
| 59 | } | ||||
| 60 | 1 | 4µs | unless ($Storable::{logcarp} && *{$Storable::{logcarp}}{CODE}) { | ||
| 61 | 1 | 100ns | require Carp; | ||
| 62 | *logcarp = sub { | ||||
| 63 | Carp::carp(@_); | ||||
| 64 | 1 | 900ns | }; | ||
| 65 | } | ||||
| 66 | 1 | 56µs | 1 | 60µs | } # spent 60µs making 1 call to Storable::BEGIN@40 |
| 67 | |||||
| 68 | # | ||||
| 69 | # They might miss :flock in Fcntl | ||||
| 70 | # | ||||
| 71 | |||||
| 72 | # spent 2.53ms (378µs+2.15) within Storable::BEGIN@72 which was called:
# once (378µs+2.15ms) by Encode::BEGIN@55 at line 81 | ||||
| 73 | 3 | 83µs | 1 | 1.92ms | if (eval { require Fcntl; 1 } && exists $Fcntl::EXPORT_TAGS{'flock'}) { # spent 1.92ms making 1 call to Exporter::import |
| 74 | Fcntl->import(':flock'); | ||||
| 75 | } else { | ||||
| 76 | eval q{ | ||||
| 77 | sub LOCK_SH () { 1 } | ||||
| 78 | sub LOCK_EX () { 2 } | ||||
| 79 | }; | ||||
| 80 | } | ||||
| 81 | 1 | 1.85ms | 1 | 2.53ms | } # spent 2.53ms making 1 call to Storable::BEGIN@72 |
| 82 | |||||
| 83 | sub CLONE { | ||||
| 84 | # clone context under threads | ||||
| 85 | Storable::init_perinterp(); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub BLESS_OK () { 2 } | ||||
| 89 | sub TIE_OK () { 4 } | ||||
| 90 | sub FLAGS_COMPAT () { BLESS_OK | TIE_OK } | ||||
| 91 | |||||
| 92 | # By default restricted hashes are downgraded on earlier perls. | ||||
| 93 | |||||
| 94 | 1 | 100ns | $Storable::flags = FLAGS_COMPAT; | ||
| 95 | 1 | 100ns | $Storable::downgrade_restricted = 1; | ||
| 96 | 1 | 100ns | $Storable::accept_future_minor = 1; | ||
| 97 | |||||
| 98 | 1 | 179µs | 1 | 172µs | XSLoader::load('Storable'); # spent 172µs making 1 call to XSLoader::load |
| 99 | |||||
| 100 | # | ||||
| 101 | # Determine whether locking is possible, but only when needed. | ||||
| 102 | # | ||||
| 103 | |||||
| 104 | sub CAN_FLOCK { 1 } # computed by Storable.pm.PL | ||||
| 105 | |||||
| 106 | sub show_file_magic { | ||||
| 107 | print <<EOM; | ||||
| 108 | # | ||||
| 109 | # To recognize the data files of the Perl module Storable, | ||||
| 110 | # the following lines need to be added to the local magic(5) file, | ||||
| 111 | # usually either /usr/share/misc/magic or /etc/magic. | ||||
| 112 | # | ||||
| 113 | 0 string perl-store perl Storable(v0.6) data | ||||
| 114 | >4 byte >0 (net-order %d) | ||||
| 115 | >>4 byte &01 (network-ordered) | ||||
| 116 | >>4 byte =3 (major 1) | ||||
| 117 | >>4 byte =2 (major 1) | ||||
| 118 | |||||
| 119 | 0 string pst0 perl Storable(v0.7) data | ||||
| 120 | >4 byte >0 | ||||
| 121 | >>4 byte &01 (network-ordered) | ||||
| 122 | >>4 byte =5 (major 2) | ||||
| 123 | >>4 byte =4 (major 2) | ||||
| 124 | >>5 byte >0 (minor %d) | ||||
| 125 | EOM | ||||
| 126 | } | ||||
| 127 | |||||
| 128 | sub file_magic { | ||||
| 129 | require IO::File; | ||||
| 130 | |||||
| 131 | my $file = shift; | ||||
| 132 | my $fh = IO::File->new; | ||||
| 133 | open($fh, "<", $file) || die "Can't open '$file': $!"; | ||||
| 134 | binmode($fh); | ||||
| 135 | defined(sysread($fh, my $buf, 32)) || die "Can't read from '$file': $!"; | ||||
| 136 | close($fh); | ||||
| 137 | |||||
| 138 | $file = "./$file" unless $file; # ensure TRUE value | ||||
| 139 | |||||
| 140 | return read_magic($buf, $file); | ||||
| 141 | } | ||||
| 142 | |||||
| 143 | sub read_magic { | ||||
| 144 | my($buf, $file) = @_; | ||||
| 145 | my %info; | ||||
| 146 | |||||
| 147 | my $buflen = length($buf); | ||||
| 148 | my $magic; | ||||
| 149 | if ($buf =~ s/^(pst0|perl-store)//) { | ||||
| 150 | $magic = $1; | ||||
| 151 | $info{file} = $file || 1; | ||||
| 152 | } | ||||
| 153 | else { | ||||
| 154 | return undef if $file; | ||||
| 155 | $magic = ""; | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | return undef unless length($buf); | ||||
| 159 | |||||
| 160 | my $net_order; | ||||
| 161 | if ($magic eq "perl-store" && ord(substr($buf, 0, 1)) > 1) { | ||||
| 162 | $info{version} = -1; | ||||
| 163 | $net_order = 0; | ||||
| 164 | } | ||||
| 165 | else { | ||||
| 166 | $buf =~ s/(.)//s; | ||||
| 167 | my $major = (ord $1) >> 1; | ||||
| 168 | return undef if $major > 4; # sanity (assuming we never go that high) | ||||
| 169 | $info{major} = $major; | ||||
| 170 | $net_order = (ord $1) & 0x01; | ||||
| 171 | if ($major > 1) { | ||||
| 172 | return undef unless $buf =~ s/(.)//s; | ||||
| 173 | my $minor = ord $1; | ||||
| 174 | $info{minor} = $minor; | ||||
| 175 | $info{version} = "$major.$minor"; | ||||
| 176 | $info{version_nv} = sprintf "%d.%03d", $major, $minor; | ||||
| 177 | } | ||||
| 178 | else { | ||||
| 179 | $info{version} = $major; | ||||
| 180 | } | ||||
| 181 | } | ||||
| 182 | $info{version_nv} ||= $info{version}; | ||||
| 183 | $info{netorder} = $net_order; | ||||
| 184 | |||||
| 185 | unless ($net_order) { | ||||
| 186 | return undef unless $buf =~ s/(.)//s; | ||||
| 187 | my $len = ord $1; | ||||
| 188 | return undef unless length($buf) >= $len; | ||||
| 189 | return undef unless $len == 4 || $len == 8; # sanity | ||||
| 190 | @info{qw(byteorder intsize longsize ptrsize)} | ||||
| 191 | = unpack "a${len}CCC", $buf; | ||||
| 192 | (substr $buf, 0, $len + 3) = ''; | ||||
| 193 | if ($info{version_nv} >= 2.002) { | ||||
| 194 | return undef unless $buf =~ s/(.)//s; | ||||
| 195 | $info{nvsize} = ord $1; | ||||
| 196 | } | ||||
| 197 | } | ||||
| 198 | $info{hdrsize} = $buflen - length($buf); | ||||
| 199 | |||||
| 200 | return \%info; | ||||
| 201 | } | ||||
| 202 | |||||
| 203 | sub BIN_VERSION_NV { | ||||
| 204 | sprintf "%d.%03d", BIN_MAJOR(), BIN_MINOR(); | ||||
| 205 | } | ||||
| 206 | |||||
| 207 | sub BIN_WRITE_VERSION_NV { | ||||
| 208 | sprintf "%d.%03d", BIN_MAJOR(), BIN_WRITE_MINOR(); | ||||
| 209 | } | ||||
| 210 | |||||
| 211 | # | ||||
| 212 | # store | ||||
| 213 | # | ||||
| 214 | # Store target object hierarchy, identified by a reference to its root. | ||||
| 215 | # The stored object tree may later be retrieved to memory via retrieve. | ||||
| 216 | # Returns undef if an I/O error occurred, in which case the file is | ||||
| 217 | # removed. | ||||
| 218 | # | ||||
| 219 | sub store { | ||||
| 220 | return _store(\&pstore, @_, 0); | ||||
| 221 | } | ||||
| 222 | |||||
| 223 | # | ||||
| 224 | # nstore | ||||
| 225 | # | ||||
| 226 | # Same as store, but in network order. | ||||
| 227 | # | ||||
| 228 | sub nstore { | ||||
| 229 | return _store(\&net_pstore, @_, 0); | ||||
| 230 | } | ||||
| 231 | |||||
| 232 | # | ||||
| 233 | # lock_store | ||||
| 234 | # | ||||
| 235 | # Same as store, but flock the file first (advisory locking). | ||||
| 236 | # | ||||
| 237 | sub lock_store { | ||||
| 238 | return _store(\&pstore, @_, 1); | ||||
| 239 | } | ||||
| 240 | |||||
| 241 | # | ||||
| 242 | # lock_nstore | ||||
| 243 | # | ||||
| 244 | # Same as nstore, but flock the file first (advisory locking). | ||||
| 245 | # | ||||
| 246 | sub lock_nstore { | ||||
| 247 | return _store(\&net_pstore, @_, 1); | ||||
| 248 | } | ||||
| 249 | |||||
| 250 | # Internal store to file routine | ||||
| 251 | sub _store { | ||||
| 252 | my $xsptr = shift; | ||||
| 253 | my $self = shift; | ||||
| 254 | my ($file, $use_locking) = @_; | ||||
| 255 | logcroak "not a reference" unless ref($self); | ||||
| 256 | logcroak "wrong argument number" unless @_ == 2; # No @foo in arglist | ||||
| 257 | local *FILE; | ||||
| 258 | if ($use_locking) { | ||||
| 259 | open(FILE, ">>", $file) || logcroak "can't write into $file: $!"; | ||||
| 260 | unless (1) { | ||||
| 261 | logcarp | ||||
| 262 | "Storable::lock_store: fcntl/flock emulation broken on $^O"; | ||||
| 263 | return undef; | ||||
| 264 | } | ||||
| 265 | flock(FILE, LOCK_EX) || | ||||
| 266 | logcroak "can't get exclusive lock on $file: $!"; | ||||
| 267 | truncate FILE, 0; | ||||
| 268 | # Unlocking will happen when FILE is closed | ||||
| 269 | } else { | ||||
| 270 | open(FILE, ">", $file) || logcroak "can't create $file: $!"; | ||||
| 271 | } | ||||
| 272 | binmode FILE; # Archaic systems... | ||||
| 273 | my $da = $@; # Don't mess if called from exception handler | ||||
| 274 | my $ret; | ||||
| 275 | # Call C routine nstore or pstore, depending on network order | ||||
| 276 | eval { $ret = &$xsptr(*FILE, $self) }; | ||||
| 277 | # close will return true on success, so the or short-circuits, the () | ||||
| 278 | # expression is true, and for that case the block will only be entered | ||||
| 279 | # if $@ is true (ie eval failed) | ||||
| 280 | # if close fails, it returns false, $ret is altered, *that* is (also) | ||||
| 281 | # false, so the () expression is false, !() is true, and the block is | ||||
| 282 | # entered. | ||||
| 283 | if (!(close(FILE) or undef $ret) || $@) { | ||||
| 284 | unlink($file) or warn "Can't unlink $file: $!\n"; | ||||
| 285 | } | ||||
| 286 | if ($@) { | ||||
| 287 | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||
| 288 | logcroak $@; | ||||
| 289 | } | ||||
| 290 | $@ = $da; | ||||
| 291 | return $ret; | ||||
| 292 | } | ||||
| 293 | |||||
| 294 | # | ||||
| 295 | # store_fd | ||||
| 296 | # | ||||
| 297 | # Same as store, but perform on an already opened file descriptor instead. | ||||
| 298 | # Returns undef if an I/O error occurred. | ||||
| 299 | # | ||||
| 300 | sub store_fd { | ||||
| 301 | return _store_fd(\&pstore, @_); | ||||
| 302 | } | ||||
| 303 | |||||
| 304 | # | ||||
| 305 | # nstore_fd | ||||
| 306 | # | ||||
| 307 | # Same as store_fd, but in network order. | ||||
| 308 | # | ||||
| 309 | sub nstore_fd { | ||||
| 310 | my ($self, $file) = @_; | ||||
| 311 | return _store_fd(\&net_pstore, @_); | ||||
| 312 | } | ||||
| 313 | |||||
| 314 | # Internal store routine on opened file descriptor | ||||
| 315 | sub _store_fd { | ||||
| 316 | my $xsptr = shift; | ||||
| 317 | my $self = shift; | ||||
| 318 | my ($file) = @_; | ||||
| 319 | logcroak "not a reference" unless ref($self); | ||||
| 320 | logcroak "too many arguments" unless @_ == 1; # No @foo in arglist | ||||
| 321 | my $fd = fileno($file); | ||||
| 322 | logcroak "not a valid file descriptor" unless defined $fd; | ||||
| 323 | my $da = $@; # Don't mess if called from exception handler | ||||
| 324 | my $ret; | ||||
| 325 | # Call C routine nstore or pstore, depending on network order | ||||
| 326 | eval { $ret = &$xsptr($file, $self) }; | ||||
| 327 | logcroak $@ if $@ =~ s/\.?\n$/,/; | ||||
| 328 | local $\; print $file ''; # Autoflush the file if wanted | ||||
| 329 | $@ = $da; | ||||
| 330 | return $ret; | ||||
| 331 | } | ||||
| 332 | |||||
| 333 | # | ||||
| 334 | # freeze | ||||
| 335 | # | ||||
| 336 | # Store object and its hierarchy in memory and return a scalar | ||||
| 337 | # containing the result. | ||||
| 338 | # | ||||
| 339 | sub freeze { | ||||
| 340 | _freeze(\&mstore, @_); | ||||
| 341 | } | ||||
| 342 | |||||
| 343 | # | ||||
| 344 | # nfreeze | ||||
| 345 | # | ||||
| 346 | # Same as freeze but in network order. | ||||
| 347 | # | ||||
| 348 | sub nfreeze { | ||||
| 349 | _freeze(\&net_mstore, @_); | ||||
| 350 | } | ||||
| 351 | |||||
| 352 | # Internal freeze routine | ||||
| 353 | sub _freeze { | ||||
| 354 | my $xsptr = shift; | ||||
| 355 | my $self = shift; | ||||
| 356 | logcroak "not a reference" unless ref($self); | ||||
| 357 | logcroak "too many arguments" unless @_ == 0; # No @foo in arglist | ||||
| 358 | my $da = $@; # Don't mess if called from exception handler | ||||
| 359 | my $ret; | ||||
| 360 | # Call C routine mstore or net_mstore, depending on network order | ||||
| 361 | eval { $ret = &$xsptr($self) }; | ||||
| 362 | if ($@) { | ||||
| 363 | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||
| 364 | logcroak $@; | ||||
| 365 | } | ||||
| 366 | $@ = $da; | ||||
| 367 | return $ret ? $ret : undef; | ||||
| 368 | } | ||||
| 369 | |||||
| 370 | # | ||||
| 371 | # retrieve | ||||
| 372 | # | ||||
| 373 | # Retrieve object hierarchy from disk, returning a reference to the root | ||||
| 374 | # object of that tree. | ||||
| 375 | # | ||||
| 376 | # retrieve(file, flags) | ||||
| 377 | # flags include by default BLESS_OK=2 | TIE_OK=4 | ||||
| 378 | # with flags=0 or the global $Storable::flags set to 0, no resulting object | ||||
| 379 | # will be blessed nor tied. | ||||
| 380 | # | ||||
| 381 | sub retrieve { | ||||
| 382 | _retrieve(shift, 0, @_); | ||||
| 383 | } | ||||
| 384 | |||||
| 385 | # | ||||
| 386 | # lock_retrieve | ||||
| 387 | # | ||||
| 388 | # Same as retrieve, but with advisory locking. | ||||
| 389 | # | ||||
| 390 | sub lock_retrieve { | ||||
| 391 | _retrieve(shift, 1, @_); | ||||
| 392 | } | ||||
| 393 | |||||
| 394 | # Internal retrieve routine | ||||
| 395 | sub _retrieve { | ||||
| 396 | my ($file, $use_locking, $flags) = @_; | ||||
| 397 | $flags = $Storable::flags unless defined $flags; | ||||
| 398 | my $FILE; | ||||
| 399 | open($FILE, "<", $file) || logcroak "can't open $file: $!"; | ||||
| 400 | binmode $FILE; # Archaic systems... | ||||
| 401 | my $self; | ||||
| 402 | my $da = $@; # Could be from exception handler | ||||
| 403 | if ($use_locking) { | ||||
| 404 | unless (1) { | ||||
| 405 | logcarp | ||||
| 406 | "Storable::lock_store: fcntl/flock emulation broken on $^O"; | ||||
| 407 | return undef; | ||||
| 408 | } | ||||
| 409 | flock($FILE, LOCK_SH) || logcroak "can't get shared lock on $file: $!"; | ||||
| 410 | # Unlocking will happen when FILE is closed | ||||
| 411 | } | ||||
| 412 | eval { $self = pretrieve($FILE, $flags) }; # Call C routine | ||||
| 413 | close($FILE); | ||||
| 414 | if ($@) { | ||||
| 415 | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||
| 416 | logcroak $@; | ||||
| 417 | } | ||||
| 418 | $@ = $da; | ||||
| 419 | return $self; | ||||
| 420 | } | ||||
| 421 | |||||
| 422 | # | ||||
| 423 | # fd_retrieve | ||||
| 424 | # | ||||
| 425 | # Same as retrieve, but perform from an already opened file descriptor instead. | ||||
| 426 | # | ||||
| 427 | sub fd_retrieve { | ||||
| 428 | my ($file, $flags) = @_; | ||||
| 429 | $flags = $Storable::flags unless defined $flags; | ||||
| 430 | my $fd = fileno($file); | ||||
| 431 | logcroak "not a valid file descriptor" unless defined $fd; | ||||
| 432 | my $self; | ||||
| 433 | my $da = $@; # Could be from exception handler | ||||
| 434 | eval { $self = pretrieve($file, $flags) }; # Call C routine | ||||
| 435 | if ($@) { | ||||
| 436 | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||
| 437 | logcroak $@; | ||||
| 438 | } | ||||
| 439 | $@ = $da; | ||||
| 440 | return $self; | ||||
| 441 | } | ||||
| 442 | |||||
| 443 | sub retrieve_fd { &fd_retrieve } # Backward compatibility | ||||
| 444 | |||||
| 445 | # | ||||
| 446 | # thaw | ||||
| 447 | # | ||||
| 448 | # Recreate objects in memory from an existing frozen image created | ||||
| 449 | # by freeze. If the frozen image passed is undef, return undef. | ||||
| 450 | # | ||||
| 451 | # thaw(frozen_obj, flags) | ||||
| 452 | # flags include by default BLESS_OK=2 | TIE_OK=4 | ||||
| 453 | # with flags=0 or the global $Storable::flags set to 0, no resulting object | ||||
| 454 | # will be blessed nor tied. | ||||
| 455 | # | ||||
| 456 | sub thaw { | ||||
| 457 | my ($frozen, $flags) = @_; | ||||
| 458 | $flags = $Storable::flags unless defined $flags; | ||||
| 459 | return undef unless defined $frozen; | ||||
| 460 | my $self; | ||||
| 461 | my $da = $@; # Could be from exception handler | ||||
| 462 | eval { $self = mretrieve($frozen, $flags) };# Call C routine | ||||
| 463 | if ($@) { | ||||
| 464 | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||
| 465 | logcroak $@; | ||||
| 466 | } | ||||
| 467 | $@ = $da; | ||||
| 468 | return $self; | ||||
| 469 | } | ||||
| 470 | |||||
| 471 | # | ||||
| 472 | # _make_re($re, $flags) | ||||
| 473 | # | ||||
| 474 | # Internal function used to thaw a regular expression. | ||||
| 475 | # | ||||
| 476 | |||||
| 477 | 1 | 200ns | my $re_flags; | ||
| 478 | # spent 18µs (15+3) within Storable::BEGIN@478 which was called:
# once (15µs+3µs) by Encode::BEGIN@55 at line 491 | ||||
| 479 | 1 | 3µs | if ($] < 5.010) { | ||
| 480 | $re_flags = qr/\A[imsx]*\z/; | ||||
| 481 | } | ||||
| 482 | elsif ($] < 5.014) { | ||||
| 483 | $re_flags = qr/\A[msixp]*\z/; | ||||
| 484 | } | ||||
| 485 | elsif ($] < 5.022) { | ||||
| 486 | $re_flags = qr/\A[msixpdual]*\z/; | ||||
| 487 | } | ||||
| 488 | else { | ||||
| 489 | 1 | 13µs | 1 | 3µs | $re_flags = qr/\A[msixpdualn]*\z/; # spent 3µs making 1 call to Storable::CORE:qr |
| 490 | } | ||||
| 491 | 1 | 122µs | 1 | 18µs | } # spent 18µs making 1 call to Storable::BEGIN@478 |
| 492 | |||||
| 493 | sub _make_re { | ||||
| 494 | my ($re, $flags) = @_; | ||||
| 495 | |||||
| 496 | $flags =~ $re_flags | ||||
| 497 | or die "regexp flags invalid"; | ||||
| 498 | |||||
| 499 | my $qr = eval "qr/\$re/$flags"; | ||||
| 500 | die $@ if $@; | ||||
| 501 | |||||
| 502 | $qr; | ||||
| 503 | } | ||||
| 504 | |||||
| 505 | 1 | 500ns | if ($] < 5.012) { | ||
| 506 | eval <<'EOS' | ||||
| 507 | sub _regexp_pattern { | ||||
| 508 | my $re = "" . shift; | ||||
| 509 | $re =~ /\A\(\?([xism]*)(?:-[xism]*)?:(.*)\)\z/s | ||||
| 510 | or die "Cannot parse regexp /$re/"; | ||||
| 511 | return ($2, $1); | ||||
| 512 | } | ||||
| 513 | 1 | ||||
| 514 | EOS | ||||
| 515 | or die "Cannot define _regexp_pattern: $@"; | ||||
| 516 | } | ||||
| 517 | |||||
| 518 | 1 | 12µs | 1; | ||
| 519 | __END__ | ||||
# spent 3µs within Storable::CORE:qr which was called:
# once (3µs+0s) by Storable::BEGIN@478 at line 489 |