| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Params/Util.pm |
| Statements | Executed 47 statements in 8.11ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3745 | 4 | 2 | 19.3ms | 19.3ms | Params::Util::_CODELIKE (xsub) |
| 368 | 2 | 1 | 1.67ms | 1.67ms | Params::Util::_SCALAR0 (xsub) |
| 1 | 1 | 1 | 100µs | 100µs | Params::Util::BEGIN@58 |
| 1 | 1 | 1 | 95µs | 95µs | Params::Util::bootstrap (xsub) |
| 13 | 1 | 1 | 81µs | 81µs | Params::Util::_HASHLIKE (xsub) |
| 13 | 1 | 1 | 64µs | 64µs | Params::Util::_ARRAYLIKE (xsub) |
| 1 | 1 | 1 | 37µs | 53µs | Params::Util::BEGIN@59 |
| 1 | 1 | 1 | 35µs | 376µs | Params::Util::BEGIN@65 |
| 2 | 1 | 1 | 13µs | 13µs | Params::Util::_HASH (xsub) |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Params::Util; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| - - | |||||
| 58 | 3 | 145µs | 1 | 100µs | # spent 100µs within Params::Util::BEGIN@58 which was called:
# once (100µs+0s) by Data::OptList::BEGIN@7 at line 58 # spent 100µs making 1 call to Params::Util::BEGIN@58 |
| 59 | 3 | 159µs | 2 | 70µs | # spent 53µs (37+16) within Params::Util::BEGIN@59 which was called:
# once (37µs+16µs) by Data::OptList::BEGIN@7 at line 59 # spent 53µs making 1 call to Params::Util::BEGIN@59
# spent 16µs making 1 call to strict::import |
| 60 | 1 | 2.88ms | require overload; | ||
| 61 | 1 | 4µs | require Exporter; | ||
| 62 | 1 | 3µs | require Scalar::Util; | ||
| 63 | 1 | 322µs | require DynaLoader; | ||
| 64 | |||||
| 65 | 3 | 1.84ms | 2 | 716µs | # spent 376µs (35+341) within Params::Util::BEGIN@65 which was called:
# once (35µs+341µs) by Data::OptList::BEGIN@7 at line 65 # spent 376µs making 1 call to Params::Util::BEGIN@65
# spent 341µs making 1 call to vars::import |
| 66 | |||||
| 67 | 1 | 4µs | $VERSION = '1.01'; | ||
| 68 | 1 | 47µs | @ISA = qw{ | ||
| 69 | Exporter | ||||
| 70 | DynaLoader | ||||
| 71 | }; | ||||
| 72 | 1 | 20µs | @EXPORT_OK = qw{ | ||
| 73 | _STRING _IDENTIFIER | ||||
| 74 | _CLASS _CLASSISA _SUBCLASS _DRIVER | ||||
| 75 | _NUMBER _POSINT _NONNEGINT | ||||
| 76 | _SCALAR _SCALAR0 | ||||
| 77 | _ARRAY _ARRAY0 _ARRAYLIKE | ||||
| 78 | _HASH _HASH0 _HASHLIKE | ||||
| 79 | _CODE _CODELIKE | ||||
| 80 | _INVOCANT _REGEX _INSTANCE | ||||
| 81 | _SET _SET0 | ||||
| 82 | _HANDLE | ||||
| 83 | }; | ||||
| 84 | 1 | 6µs | %EXPORT_TAGS = ( ALL => \@EXPORT_OK ); | ||
| 85 | |||||
| 86 | 4 | 40µs | eval { | ||
| 87 | local $ENV{PERL_DL_NONLAZY} = 0 if $ENV{PERL_DL_NONLAZY}; | ||||
| 88 | 1 | 1.11ms | bootstrap Params::Util $VERSION; # spent 1.11ms making 1 call to DynaLoader::bootstrap | ||
| 89 | 1; | ||||
| 90 | } unless $ENV{PERL_PARAMS_UTIL_PP}; | ||||
| 91 | |||||
| - - | |||||
| 96 | ##################################################################### | ||||
| 97 | # Param Checking Functions | ||||
| 98 | |||||
| 99 | =pod | ||||
| 100 | |||||
| - - | |||||
| 124 | 1 | 4µs | eval <<'END_PERL' unless defined &_STRING; | ||
| 125 | sub _STRING ($) { | ||||
| 126 | (defined $_[0] and ! ref $_[0] and length($_[0])) ? $_[0] : undef; | ||||
| 127 | } | ||||
| 128 | END_PERL | ||||
| 129 | |||||
| 130 | =pod | ||||
| 131 | |||||
| - - | |||||
| 143 | 1 | 268µs | eval <<'END_PERL' unless defined &_IDENTIFIER; | ||
| 144 | sub _IDENTIFIER ($) { | ||||
| 145 | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*\z/s) ? $_[0] : undef; | ||||
| 146 | } | ||||
| 147 | END_PERL | ||||
| 148 | |||||
| 149 | =pod | ||||
| 150 | |||||
| - - | |||||
| 166 | 1 | 196µs | eval <<'END_PERL' unless defined &_CLASS; | ||
| 167 | sub _CLASS ($) { | ||||
| 168 | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef; | ||||
| 169 | } | ||||
| 170 | END_PERL | ||||
| 171 | |||||
| 172 | =pod | ||||
| 173 | |||||
| - - | |||||
| 192 | 1 | 216µs | eval <<'END_PERL' unless defined &_CLASSISA; # spent 0s executing statements in string eval | ||
| 193 | sub _CLASSISA ($$) { | ||||
| 194 | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s and $_[0]->isa($_[1])) ? $_[0] : undef; | ||||
| 195 | } | ||||
| 196 | END_PERL | ||||
| 197 | |||||
| 198 | =pod | ||||
| 199 | |||||
| - - | |||||
| 218 | 1 | 231µs | eval <<'END_PERL' unless defined &_SUBCLASS; | ||
| 219 | sub _SUBCLASS ($$) { | ||||
| 220 | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s and $_[0] ne $_[1] and $_[0]->isa($_[1])) ? $_[0] : undef; | ||||
| 221 | } | ||||
| 222 | END_PERL | ||||
| 223 | |||||
| 224 | =pod | ||||
| 225 | |||||
| - - | |||||
| 240 | 1 | 3µs | eval <<'END_PERL' unless defined &_NUMBER; | ||
| 241 | sub _NUMBER ($) { | ||||
| 242 | ( defined $_[0] and ! ref $_[0] and Scalar::Util::looks_like_number($_[0]) ) | ||||
| 243 | ? $_[0] | ||||
| 244 | : undef; | ||||
| 245 | } | ||||
| 246 | END_PERL | ||||
| 247 | |||||
| 248 | =pod | ||||
| 249 | |||||
| - - | |||||
| 264 | 1 | 168µs | eval <<'END_PERL' unless defined &_POSINT; | ||
| 265 | sub _POSINT ($) { | ||||
| 266 | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[1-9]\d*$/) ? $_[0] : undef; | ||||
| 267 | } | ||||
| 268 | END_PERL | ||||
| 269 | |||||
| 270 | =pod | ||||
| 271 | |||||
| - - | |||||
| 294 | 1 | 180µs | eval <<'END_PERL' unless defined &_NONNEGINT; | ||
| 295 | sub _NONNEGINT ($) { | ||||
| 296 | (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^(?:0|[1-9]\d*)$/) ? $_[0] : undef; | ||||
| 297 | } | ||||
| 298 | END_PERL | ||||
| 299 | |||||
| 300 | =pod | ||||
| 301 | |||||
| - - | |||||
| 316 | 1 | 3µs | eval <<'END_PERL' unless defined &_SCALAR; | ||
| 317 | sub _SCALAR ($) { | ||||
| 318 | (ref $_[0] eq 'SCALAR' and defined ${$_[0]} and ${$_[0]} ne '') ? $_[0] : undef; | ||||
| 319 | } | ||||
| 320 | END_PERL | ||||
| 321 | |||||
| 322 | =pod | ||||
| 323 | |||||
| - - | |||||
| 338 | 1 | 2µs | eval <<'END_PERL' unless defined &_SCALAR0; | ||
| 339 | sub _SCALAR0 ($) { | ||||
| 340 | ref $_[0] eq 'SCALAR' ? $_[0] : undef; | ||||
| 341 | } | ||||
| 342 | END_PERL | ||||
| 343 | |||||
| 344 | =pod | ||||
| 345 | |||||
| - - | |||||
| 360 | 1 | 2µs | eval <<'END_PERL' unless defined &_ARRAY; | ||
| 361 | sub _ARRAY ($) { | ||||
| 362 | (ref $_[0] eq 'ARRAY' and @{$_[0]}) ? $_[0] : undef; | ||||
| 363 | } | ||||
| 364 | END_PERL | ||||
| 365 | |||||
| 366 | =pod | ||||
| 367 | |||||
| - - | |||||
| 383 | 1 | 2µs | eval <<'END_PERL' unless defined &_ARRAY0; | ||
| 384 | sub _ARRAY0 ($) { | ||||
| 385 | ref $_[0] eq 'ARRAY' ? $_[0] : undef; | ||||
| 386 | } | ||||
| 387 | END_PERL | ||||
| 388 | |||||
| 389 | =pod | ||||
| 390 | |||||
| - - | |||||
| 399 | 1 | 2µs | eval <<'END_PERL' unless defined &_ARRAYLIKE; | ||
| 400 | sub _ARRAYLIKE { | ||||
| 401 | (defined $_[0] and ref $_[0] and ( | ||||
| 402 | (Scalar::Util::reftype($_[0]) eq 'ARRAY') | ||||
| 403 | or | ||||
| 404 | overload::Method($_[0], '@{}') | ||||
| 405 | )) ? $_[0] : undef; | ||||
| 406 | } | ||||
| 407 | END_PERL | ||||
| 408 | |||||
| 409 | =pod | ||||
| 410 | |||||
| - - | |||||
| 425 | 1 | 2µs | eval <<'END_PERL' unless defined &_HASH; | ||
| 426 | sub _HASH ($) { | ||||
| 427 | (ref $_[0] eq 'HASH' and scalar %{$_[0]}) ? $_[0] : undef; | ||||
| 428 | } | ||||
| 429 | END_PERL | ||||
| 430 | |||||
| 431 | =pod | ||||
| 432 | |||||
| - - | |||||
| 447 | 1 | 2µs | eval <<'END_PERL' unless defined &_HASH0; | ||
| 448 | sub _HASH0 ($) { | ||||
| 449 | ref $_[0] eq 'HASH' ? $_[0] : undef; | ||||
| 450 | } | ||||
| 451 | END_PERL | ||||
| 452 | |||||
| 453 | =pod | ||||
| 454 | |||||
| - - | |||||
| 463 | 1 | 2µs | eval <<'END_PERL' unless defined &_HASHLIKE; | ||
| 464 | sub _HASHLIKE { | ||||
| 465 | (defined $_[0] and ref $_[0] and ( | ||||
| 466 | (Scalar::Util::reftype($_[0]) eq 'HASH') | ||||
| 467 | or | ||||
| 468 | overload::Method($_[0], '%{}') | ||||
| 469 | )) ? $_[0] : undef; | ||||
| 470 | } | ||||
| 471 | END_PERL | ||||
| 472 | |||||
| 473 | =pod | ||||
| 474 | |||||
| - - | |||||
| 486 | 1 | 2µs | eval <<'END_PERL' unless defined &_CODE; | ||
| 487 | sub _CODE ($) { | ||||
| 488 | ref $_[0] eq 'CODE' ? $_[0] : undef; | ||||
| 489 | } | ||||
| 490 | END_PERL | ||||
| 491 | |||||
| 492 | =pod | ||||
| 493 | |||||
| - - | |||||
| 534 | 1 | 2µs | eval <<'END_PERL' unless defined &_CODELIKE; | ||
| 535 | sub _CODELIKE($) { | ||||
| 536 | ( | ||||
| 537 | (Scalar::Util::reftype($_[0])||'') eq 'CODE' | ||||
| 538 | or | ||||
| 539 | Scalar::Util::blessed($_[0]) and overload::Method($_[0],'&{}') | ||||
| 540 | ) | ||||
| 541 | ? $_[0] : undef; | ||||
| 542 | } | ||||
| 543 | END_PERL | ||||
| 544 | |||||
| 545 | =pod | ||||
| 546 | |||||
| - - | |||||
| 557 | 1 | 184µs | eval <<'END_PERL' unless defined &_INVOCANT; | ||
| 558 | sub _INVOCANT($) { | ||||
| 559 | (defined $_[0] and | ||||
| 560 | (defined Scalar::Util::blessed($_[0]) | ||||
| 561 | or | ||||
| 562 | # We used to check for stash definedness, but any class-like name is a | ||||
| 563 | # valid invocant for UNIVERSAL methods, so we stopped. -- rjbs, 2006-07-02 | ||||
| 564 | Params::Util::_CLASS($_[0])) | ||||
| 565 | ) ? $_[0] : undef; | ||||
| 566 | } | ||||
| 567 | END_PERL | ||||
| 568 | |||||
| 569 | =pod | ||||
| 570 | |||||
| - - | |||||
| 582 | 1 | 5µs | eval <<'END_PERL' unless defined &_INSTANCE; | ||
| 583 | sub _INSTANCE ($$) { | ||||
| 584 | (Scalar::Util::blessed($_[0]) and $_[0]->isa($_[1])) ? $_[0] : undef; | ||||
| 585 | } | ||||
| 586 | END_PERL | ||||
| 587 | |||||
| 588 | =pod | ||||
| 589 | |||||
| - - | |||||
| 600 | 1 | 3µs | eval <<'END_PERL' unless defined &_REGEX; | ||
| 601 | sub _REGEX ($) { | ||||
| 602 | (defined $_[0] and 'Regexp' eq ref($_[0])) ? $_[0] : undef; | ||||
| 603 | } | ||||
| 604 | END_PERL | ||||
| 605 | |||||
| 606 | =pod | ||||
| 607 | |||||
| - - | |||||
| 625 | 1 | 201µs | eval <<'END_PERL' unless defined &_SET; | ||
| 626 | sub _SET ($$) { | ||||
| 627 | my $set = shift; | ||||
| 628 | _ARRAY($set) or return undef; | ||||
| 629 | foreach my $item ( @$set ) { | ||||
| 630 | _INSTANCE($item,$_[0]) or return undef; | ||||
| 631 | } | ||||
| 632 | $set; | ||||
| 633 | } | ||||
| 634 | END_PERL | ||||
| 635 | |||||
| 636 | =pod | ||||
| 637 | |||||
| - - | |||||
| 655 | 1 | 179µs | eval <<'END_PERL' unless defined &_SET0; | ||
| 656 | sub _SET0 ($$) { | ||||
| 657 | my $set = shift; | ||||
| 658 | _ARRAY0($set) or return undef; | ||||
| 659 | foreach my $item ( @$set ) { | ||||
| 660 | _INSTANCE($item,$_[0]) or return undef; | ||||
| 661 | } | ||||
| 662 | $set; | ||||
| 663 | } | ||||
| 664 | END_PERL | ||||
| 665 | |||||
| 666 | =pod | ||||
| 667 | |||||
| - - | |||||
| 683 | # We're doing this longhand for now. Once everything is perfect, | ||||
| 684 | # we'll compress this into something that compiles more efficiently. | ||||
| 685 | # Further, testing file handles is not something that is generally | ||||
| 686 | # done millions of times, so doing it slowly is not a big speed hit. | ||||
| 687 | 1 | 439µs | eval <<'END_PERL' unless defined &_HANDLE; | ||
| 688 | sub _HANDLE { | ||||
| 689 | my $it = shift; | ||||
| 690 | |||||
| 691 | # It has to be defined, of course | ||||
| 692 | unless ( defined $it ) { | ||||
| 693 | return undef; | ||||
| 694 | } | ||||
| 695 | |||||
| 696 | # Normal globs are considered to be file handles | ||||
| 697 | if ( ref $it eq 'GLOB' ) { | ||||
| 698 | return $it; | ||||
| 699 | } | ||||
| 700 | |||||
| 701 | # Check for a normal tied filehandle | ||||
| 702 | # Side Note: 5.5.4's tied() and can() doesn't like getting undef | ||||
| 703 | if ( tied($it) and tied($it)->can('TIEHANDLE') ) { | ||||
| 704 | return $it; | ||||
| 705 | } | ||||
| 706 | |||||
| 707 | # There are no other non-object handles that we support | ||||
| 708 | unless ( Scalar::Util::blessed($it) ) { | ||||
| 709 | return undef; | ||||
| 710 | } | ||||
| 711 | |||||
| 712 | # Check for a common base classes for conventional IO::Handle object | ||||
| 713 | if ( $it->isa('IO::Handle') ) { | ||||
| 714 | return $it; | ||||
| 715 | } | ||||
| 716 | |||||
| 717 | |||||
| 718 | # Check for tied file handles using Tie::Handle | ||||
| 719 | if ( $it->isa('Tie::Handle') ) { | ||||
| 720 | return $it; | ||||
| 721 | } | ||||
| 722 | |||||
| 723 | # IO::Scalar is not a proper seekable, but it is valid is a | ||||
| 724 | # regular file handle | ||||
| 725 | if ( $it->isa('IO::Scalar') ) { | ||||
| 726 | return $it; | ||||
| 727 | } | ||||
| 728 | |||||
| 729 | # Yet another special case for IO::String, which refuses (for now | ||||
| 730 | # anyway) to become a subclass of IO::Handle. | ||||
| 731 | if ( $it->isa('IO::String') ) { | ||||
| 732 | return $it; | ||||
| 733 | } | ||||
| 734 | |||||
| 735 | # This is not any sort of object we know about | ||||
| 736 | return undef; | ||||
| 737 | } | ||||
| 738 | END_PERL | ||||
| 739 | |||||
| 740 | =pod | ||||
| 741 | |||||
| - - | |||||
| 764 | 1 | 229µs | eval <<'END_PERL' unless defined &_DRIVER; | ||
| 765 | sub _DRIVER ($$) { | ||||
| 766 | (defined _CLASS($_[0]) and eval "require $_[0];" and ! $@ and $_[0]->isa($_[1]) and $_[0] ne $_[1]) ? $_[0] : undef; | ||||
| 767 | } | ||||
| 768 | END_PERL | ||||
| 769 | |||||
| 770 | 1 | 102µs | 1; | ||
| 771 | |||||
| 772 | =pod | ||||
| 773 | |||||
| - - | |||||
# spent 64µs within Params::Util::_ARRAYLIKE which was called 13 times, avg 5µs/call:
# 13 times (64µs+0s) by Data::OptList::__is_a at line 146 of Data/OptList.pm, avg 5µs/call | |||||
# spent 19.3ms within Params::Util::_CODELIKE which was called 3745 times, avg 5µs/call:
# 2000 times (10.1ms+0s) by Sub::Exporter::default_generator at line 856 of Sub/Exporter.pm, avg 5µs/call
# 1377 times (6.63ms+0s) by Data::OptList::__is_a at line 146 of Data/OptList.pm, avg 5µs/call
# 365 times (2.55ms+0s) by Sub::Exporter::_expand_group at line 481 of Sub/Exporter.pm, avg 7µs/call
# 3 times (19µs+0s) by Sub::Exporter::_do_import at line 771 of Sub/Exporter.pm, avg 6µs/call | |||||
# spent 13µs within Params::Util::_HASH which was called 2 times, avg 7µs/call:
# 2 times (13µs+0s) by Package::DeprecationManager::import at line 18 of Package/DeprecationManager.pm, avg 7µs/call | |||||
# spent 81µs within Params::Util::_HASHLIKE which was called 13 times, avg 6µs/call:
# 13 times (81µs+0s) by Data::OptList::__is_a at line 146 of Data/OptList.pm, avg 6µs/call | |||||
# spent 1.67ms within Params::Util::_SCALAR0 which was called 368 times, avg 5µs/call:
# 365 times (1.65ms+0s) by Sub::Exporter::_expand_group at line 481 of Sub/Exporter.pm, avg 5µs/call
# 3 times (20µs+0s) by Sub::Exporter::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Sub/Exporter.pm:544] at line 536 of Sub/Exporter.pm, avg 7µs/call | |||||
# spent 95µs within Params::Util::bootstrap which was called:
# once (95µs+0s) by DynaLoader::bootstrap at line 223 of DynaLoader.pm |