Filename | /var/www/foswikidev/core/lib/Foswiki/Macros/MAKETEXT.pm |
Statements | Executed 1332 statements in 1.79ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 3.77ms | 7.19ms | BEGIN@7.60 | Foswiki::
57 | 1 | 1 | 1.18ms | 3.90ms | MAKETEXT | Foswiki::
21 | 1 | 1 | 116µs | 116µs | _validate | Foswiki::
1 | 1 | 1 | 14µs | 27µs | BEGIN@4.58 | Foswiki::
1 | 1 | 1 | 13µs | 16µs | BEGIN@5.59 | Foswiki::
1 | 1 | 1 | 5µs | 5µs | BEGIN@9.61 | Foswiki::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki; | ||||
3 | |||||
4 | 2 | 27µs | 2 | 40µs | # spent 27µs (14+13) within Foswiki::BEGIN@4.58 which was called:
# once (14µs+13µs) by Foswiki::_expandMacroOnTopicRendering at line 4 # spent 27µs making 1 call to Foswiki::BEGIN@4.58
# spent 13µs making 1 call to strict::import |
5 | 2 | 24µs | 2 | 20µs | # spent 16µs (13+4) within Foswiki::BEGIN@5.59 which was called:
# once (13µs+4µs) by Foswiki::_expandMacroOnTopicRendering at line 5 # spent 16µs making 1 call to Foswiki::BEGIN@5.59
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 144µs | 1 | 7.19ms | # spent 7.19ms (3.77+3.42) within Foswiki::BEGIN@7.60 which was called:
# once (3.77ms+3.42ms) by Foswiki::_expandMacroOnTopicRendering at line 7 # spent 7.19ms making 1 call to Foswiki::BEGIN@7.60 |
8 | |||||
9 | # spent 5µs within Foswiki::BEGIN@9.61 which was called:
# once (5µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 14 | ||||
10 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
11 | require locale; | ||||
12 | import locale(); | ||||
13 | } | ||||
14 | 1 | 385µs | 1 | 5µs | } # spent 5µs making 1 call to Foswiki::BEGIN@9.61 |
15 | |||||
16 | # spent 3.90ms (1.18+2.72) within Foswiki::MAKETEXT which was called 57 times, avg 68µs/call:
# 57 times (1.18ms+2.72ms) by Foswiki::_expandMacroOnTopicRendering at line 3435 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 68µs/call | ||||
17 | 57 | 33µs | my ( $this, $params ) = @_; | ||
18 | |||||
19 | 57 | 35µs | my $str = $params->{_DEFAULT} || $params->{string} || ""; | ||
20 | 57 | 10µs | return "" unless $str; | ||
21 | |||||
22 | # escape everything: | ||||
23 | 57 | 70µs | $str =~ s/\[/~[/g; | ||
24 | 57 | 42µs | $str =~ s/\]/~]/g; | ||
25 | |||||
26 | # restore already escaped stuff: | ||||
27 | 57 | 27µs | $str =~ s/~~+\[/~[/g; | ||
28 | 57 | 23µs | $str =~ s/~~+\]/~]/g; | ||
29 | |||||
30 | 57 | 13µs | my $max = 0; | ||
31 | 57 | 8µs | my $min = 1; | ||
32 | 57 | 9µs | my $param_error = 0; | ||
33 | |||||
34 | # unescape parameters and calculate highest parameter number: | ||||
35 | 78 | 134µs | 21 | 116µs | $str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge; # spent 116µs making 21 calls to Foswiki::_validate, avg 6µs/call |
36 | $str =~ | ||||
37 | 57 | 24µs | s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge; | ||
38 | 57 | 6µs | return $str if ($param_error); | ||
39 | |||||
40 | # get the args to be interpolated. | ||||
41 | 57 | 28µs | my $argsStr = $params->{args} || ""; | ||
42 | |||||
43 | # Escape any escapes. | ||||
44 | 57 | 26µs | $str =~ s#\\#\\\\#g | ||
45 | if ( $Foswiki::cfg{UserInterfaceInternationalisation} | ||||
46 | && $Locale::Maketext::VERSION | ||||
47 | && $Locale::Maketext::VERSION < 1.23 ); # escape any escapes | ||||
48 | |||||
49 | 57 | 86µs | my @args = split( /\s*,\s*/, $argsStr ); | ||
50 | |||||
51 | # fill omitted args with empty strings | ||||
52 | 57 | 41µs | while ( ( scalar(@args) ) < $max ) { | ||
53 | 1 | 1µs | push( @args, '' ); | ||
54 | } | ||||
55 | |||||
56 | # do the magic: | ||||
57 | 57 | 164µs | 114 | 2.60ms | my $result = $this->i18n->maketext( $str, @args ); # spent 2.34ms making 57 calls to Foswiki::i18n, avg 41µs/call
# spent 270µs making 57 calls to Foswiki::I18N::Fallback::maketext, avg 5µs/call |
58 | |||||
59 | # replace accesskeys: | ||||
60 | 57 | 116µs | $result =~ | ||
61 | s#(^|[^&])&([a-zA-Z])#$1<span class='foswikiAccessKey'>$2</span>#g; | ||||
62 | |||||
63 | # replace escaped amperstands: | ||||
64 | 57 | 25µs | $result =~ s/&&/\&/g; | ||
65 | |||||
66 | 57 | 139µs | return $result; | ||
67 | } | ||||
68 | |||||
69 | # spent 116µs within Foswiki::_validate which was called 21 times, avg 6µs/call:
# 21 times (116µs+0s) by Foswiki::MAKETEXT at line 35, avg 6µs/call | ||||
70 | |||||
71 | #my ( $contents, $number, $max, $min, $param_error ) = @_ | ||||
72 | |||||
73 | 21 | 43µs | $_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number | ||
74 | 21 | 12µs | $_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number | ||
75 | |||||
76 | 21 | 8µs | if ( $_[1] > 100 ) { | ||
77 | $_[4] = 1; # Set error flag | ||||
78 | return | ||||
79 | "<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>"; | ||||
80 | } | ||||
81 | 21 | 8µs | if ( $_[1] < 1 ) { | ||
82 | $_[4] = 1; # Set error flag | ||||
83 | return | ||||
84 | "<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>"; | ||||
85 | } | ||||
86 | 21 | 72µs | return "[$_[0]]"; # Return the complete bracket parameter without escapes | ||
87 | } | ||||
88 | |||||
89 | 1 | 2µs | 1; | ||
90 | __END__ |