← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:52 2013

Filename/usr/share/perl/5.10/Text/Abbrev.pm
StatementsExecuted 195 statements in 430µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
311364µs364µsText::Abbrev::::abbrevText::Abbrev::abbrev
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Text::Abbrev;
2134µsrequire 5.005; # Probably works on earlier versions too.
311µsrequire Exporter;
4
51700nsour $VERSION = '1.01';
6
7=head1 NAME
8
- -
35113µs@ISA = qw(Exporter);
361600ns@EXPORT = qw(abbrev);
37
38# Usage:
39# abbrev \%foo, LIST;
40# ...
41# $long = $foo{$short};
42
43
# spent 364µs within Text::Abbrev::abbrev which was called 3 times, avg 121µs/call: # 3 times (364µs+0s) by CGI::Session::parse_dsn at line 152 of CGI/Session.pm, avg 121µs/call
sub abbrev {
4434µs my ($word, $hashref, $glob, %table, $returnvoid);
45
4632µs @_ or return; # So we don't autovivify onto @_ and trigger warning
47313µs if (ref($_[0])) { # hash reference preferably
48 $hashref = shift;
49 $returnvoid = 1;
50 } elsif (ref \$_[0] eq 'GLOB') { # is actually a glob (deprecated)
51 $hashref = \%{shift()};
52 $returnvoid = 1;
53 }
5436µs %{$hashref} = ();
55
5639µs WORD: foreach $word (@_) {
57965µs for (my $len = (length $word) - 1; $len > 0; --$len) {
584537µs my $abbrev = substr($word,0,$len);
594578µs my $seen = ++$table{$abbrev};
604579µs if ($seen == 1) { # We're the first word so far to have
61 # this abbreviation.
62 $hashref->{$abbrev} = $word;
63 } elsif ($seen == 2) { # We're the second word to have this
64 # abbreviation, so we can't use it.
65 delete $hashref->{$abbrev};
66 } else { # We're the third word to have this
67 # abbreviation, so skip to the next word.
68 next WORD;
69 }
70917µs }
71 }
72 # Non-abbreviations always get entered, even if they aren't unique
7338µs foreach $word (@_) {
74923µs $hashref->{$word} = $word;
75 }
7632µs return if $returnvoid;
77331µs if (wantarray) {
78 %{$hashref};
79 } else {
8032µs $hashref;
81 }
82}
83
8416µs1;