Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/MAKETEXT.pm |
Statements | Executed 898 statements in 4.84ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
52 | 1 | 1 | 3.55ms | 10.9ms | MAKETEXT | Foswiki::
1 | 1 | 1 | 30µs | 72µs | BEGIN@4.23 | Foswiki::
1 | 1 | 1 | 22µs | 45µs | BEGIN@5.24 | 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 | 54µs | 2 | 113µs | # spent 72µs (30+41) within Foswiki::BEGIN@4.23 which was called:
# once (30µs+41µs) by Foswiki::_expandMacroOnTopicRendering at line 4 # spent 72µs making 1 call to Foswiki::BEGIN@4.23
# spent 41µs making 1 call to strict::import |
5 | 2 | 485µs | 2 | 68µs | # spent 45µs (22+23) within Foswiki::BEGIN@5.24 which was called:
# once (22µs+23µs) by Foswiki::_expandMacroOnTopicRendering at line 5 # spent 45µs making 1 call to Foswiki::BEGIN@5.24
# spent 23µs making 1 call to warnings::import |
6 | |||||
7 | # spent 10.9ms (3.55+7.30) within Foswiki::MAKETEXT which was called 52 times, avg 209µs/call:
# 52 times (3.55ms+7.30ms) by Foswiki::_expandMacroOnTopicRendering at line 3066 of /usr/local/src/github.com/foswiki/core/lib/Foswiki.pm, avg 209µs/call | ||||
8 | 893 | 4.29ms | my ( $this, $params ) = @_; | ||
9 | |||||
10 | my $str = $params->{_DEFAULT} || $params->{string} || ""; | ||||
11 | return "" unless $str; | ||||
12 | |||||
13 | # escape everything: | ||||
14 | 52 | 118µs | $str =~ s/\[/~[/g; # spent 118µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call | ||
15 | 52 | 90µs | $str =~ s/\]/~]/g; # spent 90µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call | ||
16 | |||||
17 | # restore already escaped stuff: | ||||
18 | 52 | 78µs | $str =~ s/~~\[/~[/g; # spent 78µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call | ||
19 | 52 | 71µs | $str =~ s/~~\]/~]/g; # spent 71µs making 52 calls to Foswiki::CORE:subst, avg 1µs/call | ||
20 | |||||
21 | # unescape parameters and calculate highest parameter number: | ||||
22 | my $max = 0; | ||||
23 | 60 | 128µs | $str =~ s/~\[(\_(\d+))~\]/ $max = $2 if ($2 > $max); "[$1]"/ge; # spent 110µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call
# spent 18µs making 8 calls to Foswiki::CORE:substcont, avg 2µs/call | ||
24 | $str =~ | ||||
25 | 52 | 77µs | s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ $max = $2 if ($2 > $max); "[$1]"/ge; # spent 77µs making 52 calls to Foswiki::CORE:subst, avg 1µs/call | ||
26 | |||||
27 | # get the args to be interpolated. | ||||
28 | my $argsStr = $params->{args} || ""; | ||||
29 | |||||
30 | my @args = split( /\s*,\s*/, $argsStr ); | ||||
31 | |||||
32 | # fill omitted args with empty strings | ||||
33 | while ( ( scalar @args ) < $max ) { | ||||
34 | push( @args, '' ); | ||||
35 | } | ||||
36 | |||||
37 | # do the magic: | ||||
38 | 104 | 6.49ms | my $result = $this->i18n->maketext( $str, @args ); # spent 5.01ms making 52 calls to Foswiki::i18n, avg 96µs/call
# spent 1.48ms making 52 calls to Foswiki::I18N::Fallback::maketext, avg 28µs/call | ||
39 | |||||
40 | # replace accesskeys: | ||||
41 | 74 | 177µs | $result =~ # spent 124µs making 52 calls to Foswiki::CORE:subst, avg 2µs/call
# spent 53µs making 22 calls to Foswiki::CORE:substcont, avg 2µs/call | ||
42 | s#(^|[^&])&([a-zA-Z])#$1<span class='foswikiAccessKey'>$2</span>#g; | ||||
43 | |||||
44 | # replace escaped amperstands: | ||||
45 | 52 | 78µs | $result =~ s/&&/\&/g; # spent 78µs making 52 calls to Foswiki::CORE:subst, avg 1µs/call | ||
46 | |||||
47 | return $result; | ||||
48 | } | ||||
49 | |||||
50 | 1 | 5µs | 1; | ||
51 | __END__ |