Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Prefs/Web.pm |
Statements | Executed 166 statements in 1.54ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
67 | 1 | 1 | 893µs | 3.41ms | get | Foswiki::Prefs::Web::
3 | 1 | 1 | 102µs | 102µs | new | Foswiki::Prefs::Web::
3 | 1 | 1 | 82µs | 201µs | finish | Foswiki::Prefs::Web::
1 | 1 | 1 | 24µs | 32µs | BEGIN@18 | Foswiki::Prefs::Web::
1 | 1 | 1 | 16µs | 35µs | BEGIN@19 | Foswiki::Prefs::Web::
0 | 0 | 0 | 0s | 0s | cloneStack | Foswiki::Prefs::Web::
0 | 0 | 0 | 0s | 0s | isInTopOfStack | Foswiki::Prefs::Web::
0 | 0 | 0 | 0s | 0s | stack | Foswiki::Prefs::Web::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+ UNPUBLISHED package Foswiki::Prefs::Web | ||||
6 | |||||
7 | This class is a simple wrapper around Foswiki::Prefs::Stack. Since Webs has an | ||||
8 | hierarchical structure it's needed only one stack to deal with preferences from | ||||
9 | Web and Web/Subweb and Web/Subweb/Subsubweb. This class has a reference to a | ||||
10 | stack and the level where the web is. | ||||
11 | |||||
12 | This class is used by Foswiki::Prefs to pass web preferences to Foswiki::Meta | ||||
13 | and should not be used for anything else. | ||||
14 | |||||
15 | =cut | ||||
16 | |||||
17 | package Foswiki::Prefs::Web; | ||||
18 | 2 | 45µs | 2 | 39µs | # spent 32µs (24+7) within Foswiki::Prefs::Web::BEGIN@18 which was called:
# once (24µs+7µs) by Foswiki::Prefs::BEGIN@71 at line 18 # spent 32µs making 1 call to Foswiki::Prefs::Web::BEGIN@18
# spent 8µs making 1 call to strict::import |
19 | 2 | 484µs | 2 | 53µs | # spent 35µs (16+18) within Foswiki::Prefs::Web::BEGIN@19 which was called:
# once (16µs+18µs) by Foswiki::Prefs::BEGIN@71 at line 19 # spent 35µs making 1 call to Foswiki::Prefs::Web::BEGIN@19
# spent 18µs making 1 call to warnings::import |
20 | |||||
21 | =begin TML | ||||
22 | |||||
23 | ---++ ClassMethod new( $session ) | ||||
24 | |||||
25 | Creates a new WebPrefs object. | ||||
26 | |||||
27 | =cut | ||||
28 | |||||
29 | # spent 102µs within Foswiki::Prefs::Web::new which was called 3 times, avg 34µs/call:
# 3 times (102µs+0s) by Foswiki::Prefs::_getWebPrefsObj at line 203 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Prefs.pm, avg 34µs/call | ||||
30 | 3 | 7µs | my $proto = shift; | ||
31 | 3 | 6µs | my $class = ref($proto) || $proto; | ||
32 | 3 | 7µs | my ( $stack, $level ) = @_; | ||
33 | 3 | 21µs | my $this = { | ||
34 | stack => $stack, | ||||
35 | level => $level, | ||||
36 | }; | ||||
37 | 3 | 58µs | return bless $this, $class; | ||
38 | } | ||||
39 | |||||
40 | =begin TML | ||||
41 | |||||
42 | ---++ ObjectMethod finish() | ||||
43 | |||||
44 | Break circular references. | ||||
45 | |||||
46 | =cut | ||||
47 | |||||
48 | # Note to developers; please undef *all* fields in the object explicitly, | ||||
49 | # whether they are references or not. That way this method is "golden | ||||
50 | # documentation" of the live fields in the object. | ||||
51 | # spent 201µs (82+119) within Foswiki::Prefs::Web::finish which was called 3 times, avg 67µs/call:
# 3 times (82µs+119µs) by Foswiki::Prefs::finish at line 128 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Prefs.pm, avg 67µs/call | ||||
52 | 3 | 5µs | my $this = shift; | ||
53 | 3 | 42µs | 3 | 119µs | $this->{stack}->finish() if $this->{stack}; # spent 119µs making 3 calls to Foswiki::Prefs::Stack::finish, avg 40µs/call |
54 | 3 | 11µs | undef $this->{stack}; | ||
55 | 3 | 21µs | undef $this->{level}; | ||
56 | } | ||||
57 | |||||
58 | =begin TML | ||||
59 | |||||
60 | ---++ ObjectMethod isInTopOfStack() -> $boolean | ||||
61 | |||||
62 | Returns true if this web is the hihger of the underlying stack object. | ||||
63 | |||||
64 | =cut | ||||
65 | |||||
66 | sub isInTopOfStack { | ||||
67 | my $this = shift; | ||||
68 | return $this->{level} == $this->{stack}->size() - 1; | ||||
69 | } | ||||
70 | |||||
71 | =begin TML | ||||
72 | |||||
73 | ---++ ObjectMethod stack() -> $stack | ||||
74 | |||||
75 | Read-only accessor to the underlying stack object. | ||||
76 | |||||
77 | =cut | ||||
78 | |||||
79 | sub stack { | ||||
80 | return $_[0]->{stack}; | ||||
81 | } | ||||
82 | |||||
83 | =begin TML | ||||
84 | |||||
85 | ---++ ObjectMethod cloneStack($level) -> $stack | ||||
86 | |||||
87 | This method clone the underlying stack object, to the given $level. See | ||||
88 | Foswiki::Prefs::Stack::clone documentation. | ||||
89 | |||||
90 | This method exists because WebPrefs objects are used by Foswiki::Prefs instead | ||||
91 | of bar Foswiki::Prefs::Stack and this operation is needed. | ||||
92 | |||||
93 | =cut | ||||
94 | |||||
95 | sub cloneStack { | ||||
96 | my ( $this, $level ) = @_; | ||||
97 | return $this->{stack}->clone($level); | ||||
98 | } | ||||
99 | |||||
100 | =begin TML | ||||
101 | |||||
102 | ---++ ObjectMethod get($pref) -> $value | ||||
103 | |||||
104 | Returns the $value of the given $pref. | ||||
105 | |||||
106 | =cut | ||||
107 | |||||
108 | # spent 3.41ms (893µs+2.52) within Foswiki::Prefs::Web::get which was called 67 times, avg 51µs/call:
# 67 times (893µs+2.52ms) by Foswiki::Meta::getPreference at line 662 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Meta.pm, avg 51µs/call | ||||
109 | 67 | 126µs | my ( $this, $key ) = @_; | ||
110 | 67 | 708µs | 67 | 2.52ms | $this->{stack}->getPreference( $key, $this->{level} ); # spent 2.52ms making 67 calls to Foswiki::Prefs::Stack::getPreference, avg 38µs/call |
111 | } | ||||
112 | |||||
113 | 1 | 4µs | 1; | ||
114 | __END__ |