Filename | /var/www/foswikidev/core/lib/Foswiki/Render/Parent.pm |
Statements | Executed 35 statements in 447µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 24µs | 30µs | render | Foswiki::Render::Parent::
1 | 1 | 1 | 13µs | 26µs | BEGIN@4 | Foswiki::Render::Parent::
1 | 1 | 1 | 9µs | 13µs | BEGIN@5 | Foswiki::Render::Parent::
1 | 1 | 1 | 9µs | 9µs | BEGIN@10 | Foswiki::Render::Parent::
1 | 1 | 1 | 3µs | 3µs | BEGIN@8 | Foswiki::Render::Parent::
1 | 1 | 1 | 3µs | 3µs | BEGIN@7 | Foswiki::Render::Parent::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Render::Parent; | ||||
3 | |||||
4 | 2 | 30µs | 2 | 38µs | # spent 26µs (13+12) within Foswiki::Render::Parent::BEGIN@4 which was called:
# once (13µs+12µs) by Foswiki::META at line 4 # spent 26µs making 1 call to Foswiki::Render::Parent::BEGIN@4
# spent 12µs making 1 call to strict::import |
5 | 2 | 23µs | 2 | 18µs | # spent 13µs (9+4) within Foswiki::Render::Parent::BEGIN@5 which was called:
# once (9µs+4µs) by Foswiki::META at line 5 # spent 13µs making 1 call to Foswiki::Render::Parent::BEGIN@5
# spent 4µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 18µs | 1 | 3µs | # spent 3µs within Foswiki::Render::Parent::BEGIN@7 which was called:
# once (3µs+0s) by Foswiki::META at line 7 # spent 3µs making 1 call to Foswiki::Render::Parent::BEGIN@7 |
8 | 2 | 43µs | 1 | 3µs | # spent 3µs within Foswiki::Render::Parent::BEGIN@8 which was called:
# once (3µs+0s) by Foswiki::META at line 8 # spent 3µs making 1 call to Foswiki::Render::Parent::BEGIN@8 |
9 | |||||
10 | # spent 9µs within Foswiki::Render::Parent::BEGIN@10 which was called:
# once (9µs+0s) by Foswiki::META at line 15 | ||||
11 | 1 | 10µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
12 | require locale; | ||||
13 | import locale(); | ||||
14 | } | ||||
15 | 1 | 303µs | 1 | 9µs | } # spent 9µs making 1 call to Foswiki::Render::Parent::BEGIN@10 |
16 | |||||
17 | =begin TML | ||||
18 | |||||
19 | ---++ StaticMethod render($session, $topicObject, $params) -> $text | ||||
20 | |||||
21 | Render parent meta-data. Support for %META%. | ||||
22 | |||||
23 | =cut | ||||
24 | |||||
25 | # spent 30µs (24+7) within Foswiki::Render::Parent::render which was called:
# once (24µs+7µs) by Foswiki::META at line 69 of /var/www/foswikidev/core/lib/Foswiki/Macros/META.pm | ||||
26 | 1 | 800ns | my ( $session, $topicObject, $ah ) = @_; | ||
27 | 1 | 900ns | my $dontRecurse = $ah->{dontrecurse} || 0; | ||
28 | 1 | 200ns | my $depth = $ah->{depth} || 0; | ||
29 | 1 | 600ns | my $noWebHome = $ah->{nowebhome} || 0; | ||
30 | 1 | 300ns | my $prefix = $ah->{prefix} || ''; | ||
31 | 1 | 300ns | my $suffix = $ah->{suffix} || ''; | ||
32 | 1 | 400ns | my $usesep = $ah->{separator} || ' > '; | ||
33 | 1 | 300ns | my $format = $ah->{format} || '[[$web.$topic][$topic]]'; | ||
34 | |||||
35 | 1 | 3µs | 2 | 4µs | my ( $web, $topic ) = ( $topicObject->web, $topicObject->topic ); # spent 2µs making 1 call to Foswiki::Meta::web
# spent 2µs making 1 call to Foswiki::Meta::topic |
36 | 1 | 200ns | return '' unless $web && $topic; | ||
37 | |||||
38 | 1 | 200ns | my %visited; | ||
39 | 1 | 2µs | $visited{ $web . '.' . $topic } = 1; | ||
40 | |||||
41 | 1 | 300ns | my $pWeb = $web; | ||
42 | 1 | 100ns | my $pTopic; | ||
43 | 1 | 200ns | my $text = ''; | ||
44 | 1 | 1µs | 1 | 2µs | my $parentMeta = $topicObject->get('TOPICPARENT'); # spent 2µs making 1 call to Foswiki::Meta::get |
45 | 1 | 100ns | my $parent; | ||
46 | |||||
47 | 1 | 100ns | $parent = $parentMeta->{name} if $parentMeta; | ||
48 | |||||
49 | 1 | 200ns | my @stack; | ||
50 | 1 | 200ns | my $currentDepth = 0; | ||
51 | 1 | 100ns | $depth = 1 if $dontRecurse; | ||
52 | |||||
53 | 1 | 400ns | while ($parent) { | ||
54 | $currentDepth++; | ||||
55 | ( $pWeb, $pTopic ) = $session->normalizeWebTopicName( $pWeb, $parent ); | ||||
56 | $parent = $pWeb . '.' . $pTopic; | ||||
57 | last | ||||
58 | if ( $noWebHome && ( $pTopic eq $Foswiki::cfg{HomeTopicName} ) | ||||
59 | || $visited{$parent} ); | ||||
60 | $visited{$parent} = 1; | ||||
61 | $text = $format; | ||||
62 | $text =~ s/\$web/$pWeb/g; | ||||
63 | $text =~ s/\$topic/$pTopic/g; | ||||
64 | |||||
65 | if ( !$depth or $currentDepth == $depth ) { | ||||
66 | unshift( @stack, $text ); | ||||
67 | } | ||||
68 | last if $currentDepth == $depth; | ||||
69 | |||||
70 | # Compromise; rather than supporting a hack in the store to support | ||||
71 | # rapid access to parent meta (as in TWiki) accept the hit | ||||
72 | # of reading the whole topic. | ||||
73 | my $topicObject = Foswiki::Meta->load( $session, $pWeb, $pTopic ); | ||||
74 | my $parentMeta = $topicObject->get('TOPICPARENT'); | ||||
75 | $parent = $parentMeta->{name} if $parentMeta; | ||||
76 | } | ||||
77 | 1 | 500ns | $text = join( $usesep, @stack ); | ||
78 | |||||
79 | 1 | 100ns | if ($text) { | ||
80 | $text = $prefix . $text if ($prefix); | ||||
81 | $text .= $suffix if ($suffix); | ||||
82 | } | ||||
83 | |||||
84 | 1 | 5µs | return $text; | ||
85 | } | ||||
86 | |||||
87 | 1 | 2µs | 1; | ||
88 | __END__ |