← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:15 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Macros/URLPARAM.pm
StatementsExecuted 69 statements in 581µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
31146µs120µsFoswiki::::URLPARAMFoswiki::URLPARAM
11114µs28µsFoswiki::::BEGIN@4.68Foswiki::BEGIN@4.68
31111µs11µsFoswiki::::_handleURLPARAMValueFoswiki::_handleURLPARAMValue
11110µs14µsFoswiki::::BEGIN@5.69Foswiki::BEGIN@5.69
1114µs4µsFoswiki::::BEGIN@7.70Foswiki::BEGIN@7.70
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
4228µs241µs
# spent 28µs (14+14) within Foswiki::BEGIN@4.68 which was called: # once (14µs+14µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 28µs making 1 call to Foswiki::BEGIN@4.68 # spent 14µs making 1 call to strict::import
5250µs218µs
# spent 14µs (10+4) within Foswiki::BEGIN@5.69 which was called: # once (10µs+4µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 14µs making 1 call to Foswiki::BEGIN@5.69 # spent 4µs making 1 call to warnings::import
6
7
# spent 4µs within Foswiki::BEGIN@7.70 which was called: # once (4µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 12
BEGIN {
815µs if ( $Foswiki::cfg{UseLocale} ) {
9 require locale;
10 import locale();
11 }
121447µs14µs}
# spent 4µs making 1 call to Foswiki::BEGIN@7.70
13
14
# spent 120µs (46+74) within Foswiki::URLPARAM which was called 3 times, avg 40µs/call: # 3 times (46µs+74µs) by Foswiki::_expandMacroOnTopicRendering at line 3435 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 40µs/call
sub URLPARAM {
1532µs my ( $this, $params ) = @_;
1631µs my $param = $params->{_DEFAULT} || '';
1731µs my $newLine = $params->{newline};
1831µs my $encode = $params->{encode} || 'safe';
193800ns my $multiple = $params->{multiple};
203600ns my $separator = $params->{separator};
213700ns my $default = $params->{default};
22
233800ns $separator = "\n" unless ( defined $separator );
24
253600ns my $value = '';
2632µs if ( $this->{request} ) {
2735µs37µs if ( Foswiki::isTrue($multiple) ) {
# spent 7µs making 3 calls to Foswiki::isTrue, avg 2µs/call
28 my @valueArray = $this->{request}->multi_param($param);
29 if (@valueArray) {
30
31 # join multiple values properly
32 unless ( $multiple =~ m/^on$/i ) {
33 my $item = '';
34 @valueArray = map {
35 $item = $_;
36 $_ = $multiple;
37 $_ .= $item unless (s/\$item/$item/g);
38 expandStandardEscapes($_)
39 } @valueArray;
40 }
41
42 # SMELL: the $separator is not being encoded
43 $value = join(
44 $separator,
45 map {
46 _handleURLPARAMValue( $_, $newLine, $encode, $default )
47 } @valueArray
48 );
49 }
50 else {
51 $value = $default;
52 $value = '' unless defined $value;
53 }
54 }
55 else {
5636µs357µs $value = $this->{request}->param($param);
# spent 57µs making 3 calls to Foswiki::Request::param, avg 19µs/call
5735µs311µs $value =
# spent 11µs making 3 calls to Foswiki::_handleURLPARAMValue, avg 4µs/call
58 _handleURLPARAMValue( $value, $newLine, $encode, $default );
59 }
60 }
6137µs return $value;
62}
63
64
# spent 11µs within Foswiki::_handleURLPARAMValue which was called 3 times, avg 4µs/call: # 3 times (11µs+0s) by Foswiki::URLPARAM at line 57, avg 4µs/call
sub _handleURLPARAMValue {
6532µs my ( $value, $newLine, $encode, $default ) = @_;
66
673600ns if ( defined $value ) {
68 $value =~ s/\r?\n/$newLine/g if ( defined $newLine );
69 if ( $encode =~ m/^entit(y|ies)$/i ) {
70 $value = entityEncode($value);
71 }
72 elsif ( $encode =~ m/^quotes?$/i ) {
73 $value =~
74 s/\"/\\"/g; # escape quotes with backslash (Bugs:Item3383 fix)
75 }
76 elsif ( $encode =~ m/^(off|none)$/i ) {
77
78 # no encoding
79 }
80 elsif ( $encode =~ m/^url$/i ) {
81
82 # Legacy, see ENCODE
83 #$value =~ s/\r*\n\r*/<br \/>/;
84 $value = urlEncode($value);
85 }
86 else { # safe or default
87 # entity encode ' " < > and %
88 $value =~ s/([<>%'"])/'&#'.ord($1).';'/ge;
89 }
90 }
9131µs unless ( defined $value ) {
923700ns $value = $default;
9331µs $value = '' unless defined $value;
94 }
95
96 # Block expansion of %URLPARAM in the value to prevent recursion
9731µs $value =~ s/%URLPARAM\{/%<nop>URLPARAM{/g;
9839µs return $value;
99}
100
10112µs1;
102__END__