← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Macros/URLPARAM.pm
StatementsExecuted 68 statements in 684µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
31164µs167µsFoswiki::::URLPARAMFoswiki::URLPARAM
11118µs34µsFoswiki::::BEGIN@4.45Foswiki::BEGIN@4.45
31115µs15µsFoswiki::::_handleURLPARAMValueFoswiki::_handleURLPARAMValue
11111µs18µsFoswiki::::BEGIN@5.46Foswiki::BEGIN@5.46
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
4242µs250µs
# spent 34µs (18+16) within Foswiki::BEGIN@4.45 which was called: # once (18µs+16µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 34µs making 1 call to Foswiki::BEGIN@4.45 # spent 16µs making 1 call to strict::import
52570µs225µs
# spent 18µs (11+7) within Foswiki::BEGIN@5.46 which was called: # once (11µs+7µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 18µs making 1 call to Foswiki::BEGIN@5.46 # spent 7µs making 1 call to warnings::import
6
7
# spent 167µs (64+103) within Foswiki::URLPARAM which was called 3 times, avg 56µs/call: # 3 times (64µs+103µs) by Foswiki::_expandMacroOnTopicRendering at line 3160 of /var/www/foswiki11/lib/Foswiki.pm, avg 56µs/call
sub URLPARAM {
832µs my ( $this, $params ) = @_;
934µs my $param = $params->{_DEFAULT} || '';
1032µs my $newLine = $params->{newline};
1133µs my $encode = $params->{encode} || 'safe';
1232µs my $multiple = $params->{multiple};
133800ns my $separator = $params->{separator};
143900ns my $default = $params->{default};
15
1631µs $separator = "\n" unless ( defined $separator );
17
183900ns my $value = '';
1933µs if ( $this->{request} ) {
2036µs38µs if ( Foswiki::isTrue($multiple) ) {
# spent 8µs making 3 calls to Foswiki::isTrue, avg 3µ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 {
4737µs379µs $value = $this->{request}->param($param);
# spent 79µs making 3 calls to Foswiki::Request::param, avg 26µs/call
4838µs315µs $value =
# spent 15µs making 3 calls to Foswiki::_handleURLPARAMValue, avg 5µs/call
49 _handleURLPARAMValue( $value, $newLine, $encode, $default );
50 }
51 }
52310µs return $value;
53}
54
55
# spent 15µs within Foswiki::_handleURLPARAMValue which was called 3 times, avg 5µs/call: # 3 times (15µs+0s) by Foswiki::URLPARAM at line 48, avg 5µs/call
sub _handleURLPARAMValue {
5633µs my ( $value, $newLine, $encode, $default ) = @_;
57
583800ns 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 }
8231µs unless ( defined $value ) {
833700ns $value = $default;
8431µs $value = '' unless defined $value;
85 }
86
87 # Block expansion of %URLPARAM in the value to prevent recursion
8831µs $value =~ s/%URLPARAM{/%<nop>URLPARAM{/g;
89312µs return $value;
90}
91
9213µs1;
93__END__