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