← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:27:21 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/URLPARAM.pm
StatementsExecuted 47 statements in 1.13ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
211126µs331µsFoswiki::::URLPARAMFoswiki::URLPARAM
21146µs50µsFoswiki::::_handleURLPARAMValueFoswiki::_handleURLPARAMValue
11134µs45µsFoswiki::::BEGIN@4.29Foswiki::BEGIN@4.29
11120µs47µsFoswiki::::BEGIN@5.30Foswiki::BEGIN@5.30
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2package Foswiki;
3
4256µs255µs
# spent 45µs (34+11) within Foswiki::BEGIN@4.29 which was called: # once (34µs+11µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 45µs making 1 call to Foswiki::BEGIN@4.29 # spent 11µs making 1 call to strict::import
52908µs273µs
# spent 47µs (20+27) within Foswiki::BEGIN@5.30 which was called: # once (20µs+27µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 47µs making 1 call to Foswiki::BEGIN@5.30 # spent 27µs making 1 call to warnings::import
6
7
# spent 331µs (126+205) within Foswiki::URLPARAM which was called 2 times, avg 165µs/call: # 2 times (126µs+205µs) by Foswiki::_expandMacroOnTopicRendering at line 3066 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 165µs/call
sub URLPARAM {
825µs my ( $this, $params ) = @_;
927µs my $param = $params->{_DEFAULT} || '';
1024µs my $newLine = $params->{newline};
1127µs my $encode = $params->{encode} || 'safe';
1224µs my $multiple = $params->{multiple};
1324µs my $separator = $params->{separator};
1423µs my $default = $params->{default};
15
1626µs $separator = "\n" unless ( defined $separator );
17
1824µs my $value = '';
1927µs if ( $this->{request} ) {
20216µs220µs if ( Foswiki::isTrue($multiple) ) {
# spent 20µs making 2 calls to Foswiki::isTrue, avg 10µs/call
21 my @valueArray = $this->{request}->param($param);
22 if (@valueArray) {
23
24 # join multiple values properly
25 unless ( $multiple =~ m/^on$/i ) {
26 my $item = '';
27 @valueArray = map {
28 $item = $_;
29 $_ = $multiple;
30 $_ .= $item unless (s/\$item/$item/go);
31 expandStandardEscapes($_)
32 } @valueArray;
33 }
34 $value = join(
35 $separator,
36 map {
37 _handleURLPARAMValue( $_, $newLine, $encode, $default )
38 } @valueArray
39 );
40 }
41 else {
42 $value = $default;
43 $value = '' unless defined $value;
44 }
45 }
46 else {
47218µs2135µs $value = $this->{request}->param($param);
# spent 135µs making 2 calls to Foswiki::Request::param, avg 68µs/call
48214µs250µs $value =
# spent 50µs making 2 calls to Foswiki::_handleURLPARAMValue, avg 25µs/call
49 _handleURLPARAMValue( $value, $newLine, $encode, $default );
50 }
51 }
52212µs return $value;
53}
54
55
# spent 50µs (46+4) within Foswiki::_handleURLPARAMValue which was called 2 times, avg 25µs/call: # 2 times (46µs+4µs) by Foswiki::URLPARAM at line 48, avg 25µs/call
sub _handleURLPARAMValue {
5625µs my ( $value, $newLine, $encode, $default ) = @_;
57
5823µs if ( defined $value ) {
59 $value =~ s/\r?\n/$newLine/g if ( defined $newLine );
60 if ( $encode =~ /^entit(y|ies)$/i ) {
61 $value = entityEncode($value);
62 }
63 elsif ( $encode =~ /^quotes?$/i ) {
64 $value =~
65 s/\"/\\"/go; # escape quotes with backslash (Bugs:Item3383 fix)
66 }
67 elsif ( $encode =~ /^(off|none)$/i ) {
68
69 # no encoding
70 }
71 elsif ( $encode =~ /^url$/i ) {
72
73 # Legacy, see ENCODE
74 #$value =~ s/\r*\n\r*/<br \/>/;
75 $value = urlEncode($value);
76 }
77 else { # safe or default
78 # entity encode ' " < > and %
79 $value =~ s/([<>%'"])/'&#'.ord($1).';'/ge;
80 }
81 }
8226µs unless ( defined $value ) {
8323µs $value = $default;
8424µs $value = '' unless defined $value;
85 }
86
87 # Block expansion of %URLPARAM in the value to prevent recursion
88218µs24µs $value =~ s/%URLPARAM{/%<nop>URLPARAM{/g;
# spent 4µs making 2 calls to Foswiki::CORE:subst, avg 2µs/call
89213µs return $value;
90}
91
9216µs1;
93__END__