Filename | /var/www/foswikidev/core/lib/Foswiki/Prefs/BaseBackend.pm |
Statements | Executed 3454 statements in 2.97ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
476 | 2 | 2 | 1.79ms | 1.79ms | cleanupInsertValue | Foswiki::Prefs::BaseBackend::
38 | 2 | 2 | 108µs | 108µs | new | Foswiki::Prefs::BaseBackend::
1 | 1 | 1 | 12µs | 26µs | BEGIN@14 | Foswiki::Prefs::BaseBackend::
1 | 1 | 1 | 9µs | 36µs | BEGIN@16 | Foswiki::Prefs::BaseBackend::
1 | 1 | 1 | 9µs | 13µs | BEGIN@15 | Foswiki::Prefs::BaseBackend::
1 | 1 | 1 | 4µs | 4µs | BEGIN@18 | Foswiki::Prefs::BaseBackend::
0 | 0 | 0 | 0s | 0s | finish | Foswiki::Prefs::BaseBackend::
0 | 0 | 0 | 0s | 0s | get | Foswiki::Prefs::BaseBackend::
0 | 0 | 0 | 0s | 0s | getLocal | Foswiki::Prefs::BaseBackend::
0 | 0 | 0 | 0s | 0s | insert | Foswiki::Prefs::BaseBackend::
0 | 0 | 0 | 0s | 0s | localPrefs | Foswiki::Prefs::BaseBackend::
0 | 0 | 0 | 0s | 0s | prefs | Foswiki::Prefs::BaseBackend::
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 | ---+ package Foswiki::Prefs::BaseBackend | ||||
6 | |||||
7 | This is the base module for preferences backends. Its main purpose is to | ||||
8 | document the interface and provide facilities methods. | ||||
9 | |||||
10 | =cut | ||||
11 | |||||
12 | package Foswiki::Prefs::BaseBackend; | ||||
13 | |||||
14 | 2 | 25µs | 2 | 41µs | # spent 26µs (12+14) within Foswiki::Prefs::BaseBackend::BEGIN@14 which was called:
# once (12µs+14µs) by Foswiki::Prefs::HASH::BEGIN@20 at line 14 # spent 26µs making 1 call to Foswiki::Prefs::BaseBackend::BEGIN@14
# spent 14µs making 1 call to strict::import |
15 | 2 | 26µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Prefs::BaseBackend::BEGIN@15 which was called:
# once (9µs+4µs) by Foswiki::Prefs::HASH::BEGIN@20 at line 15 # spent 13µs making 1 call to Foswiki::Prefs::BaseBackend::BEGIN@15
# spent 4µs making 1 call to warnings::import |
16 | 2 | 52µs | 2 | 63µs | # spent 36µs (9+27) within Foswiki::Prefs::BaseBackend::BEGIN@16 which was called:
# once (9µs+27µs) by Foswiki::Prefs::HASH::BEGIN@20 at line 16 # spent 36µs making 1 call to Foswiki::Prefs::BaseBackend::BEGIN@16
# spent 27µs making 1 call to Exporter::import |
17 | |||||
18 | # spent 4µs within Foswiki::Prefs::BaseBackend::BEGIN@18 which was called:
# once (4µs+0s) by Foswiki::Prefs::HASH::BEGIN@20 at line 23 | ||||
19 | 1 | 7µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
20 | require locale; | ||||
21 | import locale(); | ||||
22 | } | ||||
23 | 1 | 256µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::Prefs::BaseBackend::BEGIN@18 |
24 | |||||
25 | =begin TML | ||||
26 | |||||
27 | ---++ ClassMethod new(@_) | ||||
28 | |||||
29 | Creates a preferences backend object. | ||||
30 | |||||
31 | =cut | ||||
32 | |||||
33 | # spent 108µs within Foswiki::Prefs::BaseBackend::new which was called 38 times, avg 3µs/call:
# 29 times (76µs+0s) by Foswiki::Prefs::TopicRAM::new at line 34 of /var/www/foswikidev/core/lib/Foswiki/Prefs/TopicRAM.pm, avg 3µs/call
# 9 times (32µs+0s) by Foswiki::Prefs::HASH::new at line 33 of /var/www/foswikidev/core/lib/Foswiki/Prefs/HASH.pm, avg 4µs/call | ||||
34 | 38 | 17µs | my ( $proto, $values ) = @_; | ||
35 | 38 | 13µs | my $class = ref($proto) || $proto; | ||
36 | |||||
37 | 38 | 128µs | return bless {}, $class; | ||
38 | } | ||||
39 | |||||
40 | =begin TML | ||||
41 | |||||
42 | ---++ ObjectMethod finish() | ||||
43 | Break circular references. | ||||
44 | |||||
45 | =cut | ||||
46 | |||||
47 | # Note to developers; please undef *all* fields in the object explicitly, | ||||
48 | # whether they are references or not. That way this method is "golden | ||||
49 | # documentation" of the live fields in the object. | ||||
50 | sub finish { } | ||||
51 | |||||
52 | =begin TML | ||||
53 | |||||
54 | ---++ ObjectMethod prefs() -> @preferenceKeys | ||||
55 | |||||
56 | Return a list with the names of defined preferences. | ||||
57 | |||||
58 | =cut | ||||
59 | |||||
60 | sub prefs { | ||||
61 | ASSERT('Pure virtual method - child classes must redefine'); | ||||
62 | } | ||||
63 | |||||
64 | =begin TML | ||||
65 | |||||
66 | ---++ ObjectMethod localPrefs() -> @preferenceKeys | ||||
67 | |||||
68 | Return a list with the names of 'Local' preferences. | ||||
69 | |||||
70 | =cut | ||||
71 | |||||
72 | sub localPrefs { | ||||
73 | ASSERT('Pure virtual method - child classes must redefine'); | ||||
74 | } | ||||
75 | |||||
76 | =begin TML | ||||
77 | |||||
78 | ---++ ObjectMethod get($key) -> $value | ||||
79 | |||||
80 | Return the value of the preference $key. | ||||
81 | |||||
82 | =cut | ||||
83 | |||||
84 | sub get { | ||||
85 | ASSERT('Pure virtual method - child classes must redefine'); | ||||
86 | } | ||||
87 | |||||
88 | =begin TML | ||||
89 | |||||
90 | ---++ ObjectMethod getLocal($key) -> $value | ||||
91 | |||||
92 | Return the 'Local' value of the preference $key. | ||||
93 | |||||
94 | =cut | ||||
95 | |||||
96 | sub getLocal { | ||||
97 | ASSERT('Pure virtual method - child classes must redefine'); | ||||
98 | } | ||||
99 | |||||
100 | =begin TML | ||||
101 | |||||
102 | ---++ ObjectMethod insert($type, $key, $value ) = @_; | ||||
103 | |||||
104 | Insert the preference named $key as $value. $type can be 'Local' or 'Set'. | ||||
105 | |||||
106 | =cut | ||||
107 | |||||
108 | sub insert { | ||||
109 | ASSERT('Pure virtual method - child classes must redefine'); | ||||
110 | } | ||||
111 | |||||
112 | =begin TML | ||||
113 | |||||
114 | ---++ ObjectMethod cleanupInsertValue($value_ref) | ||||
115 | |||||
116 | Utility method that cleans $$vaue_ref for later use in insert(). | ||||
117 | |||||
118 | =cut | ||||
119 | |||||
120 | # spent 1.79ms within Foswiki::Prefs::BaseBackend::cleanupInsertValue which was called 476 times, avg 4µs/call:
# 414 times (1.60ms+0s) by Foswiki::Prefs::TopicRAM::insert at line 89 of /var/www/foswikidev/core/lib/Foswiki/Prefs/TopicRAM.pm, avg 4µs/call
# 62 times (188µs+0s) by Foswiki::Prefs::HASH::insert at line 64 of /var/www/foswikidev/core/lib/Foswiki/Prefs/HASH.pm, avg 3µs/call | ||||
121 | 476 | 133µs | my ( $this, $value_ref ) = @_; | ||
122 | |||||
123 | 476 | 91µs | return unless defined $$value_ref; | ||
124 | |||||
125 | 476 | 407µs | $$value_ref =~ tr/\r//d; # Delete \r | ||
126 | 476 | 274µs | $$value_ref =~ tr/\t/ /; # replace TAB by space | ||
127 | 476 | 200µs | $$value_ref =~ s/([^\\])\\n/$1\n/g; # replace \n by new line | ||
128 | 476 | 124µs | $$value_ref =~ s/([^\\])\\\\n/$1\\n/g; # replace \\n by \n | ||
129 | 476 | 1.22ms | $$value_ref =~ tr/`//d; # filter out dangerous chars | ||
130 | } | ||||
131 | |||||
132 | 1 | 2µs | 1; | ||
133 | __END__ |