Filename | /var/www/foswikidev/core/lib/Foswiki/Prefs/Parser.pm |
Statements | Executed 5709 statements in 7.00ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
29 | 1 | 1 | 6.95ms | 45.0ms | parse | Foswiki::Prefs::Parser::
1 | 1 | 1 | 13µs | 26µs | BEGIN@18 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 10µs | 34µs | BEGIN@20 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 9µs | 13µs | BEGIN@19 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 5µs | 5µs | BEGIN@24 | Foswiki::Prefs::Parser::
1 | 1 | 1 | 4µs | 4µs | BEGIN@22 | Foswiki::Prefs::Parser::
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::Parser | ||||
6 | |||||
7 | This Prefs-internal class is used to parse * Set and * Local statements | ||||
8 | from arbitrary text, and extract settings from meta objects. It is used | ||||
9 | by TopicPrefs to parse preference settings from topics. | ||||
10 | |||||
11 | This class does no validation or duplicate-checking on the settings; it | ||||
12 | simply returns the recognized settings in the order it sees them in. | ||||
13 | |||||
14 | =cut | ||||
15 | |||||
16 | package Foswiki::Prefs::Parser; | ||||
17 | |||||
18 | 2 | 26µs | 2 | 38µs | # spent 26µs (13+12) within Foswiki::Prefs::Parser::BEGIN@18 which was called:
# once (13µs+12µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 18 # spent 26µs making 1 call to Foswiki::Prefs::Parser::BEGIN@18
# spent 12µs making 1 call to strict::import |
19 | 2 | 23µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Prefs::Parser::BEGIN@19 which was called:
# once (9µs+4µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 19 # spent 13µs making 1 call to Foswiki::Prefs::Parser::BEGIN@19
# spent 4µs making 1 call to warnings::import |
20 | 2 | 24µs | 2 | 59µs | # spent 34µs (10+25) within Foswiki::Prefs::Parser::BEGIN@20 which was called:
# once (10µs+25µs) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 20 # spent 34µs making 1 call to Foswiki::Prefs::Parser::BEGIN@20
# spent 25µs making 1 call to Exporter::import |
21 | |||||
22 | 2 | 42µs | 1 | 4µs | # spent 4µs within Foswiki::Prefs::Parser::BEGIN@22 which was called:
# once (4µs+0s) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 22 # spent 4µs making 1 call to Foswiki::Prefs::Parser::BEGIN@22 |
23 | |||||
24 | # spent 5µs within Foswiki::Prefs::Parser::BEGIN@24 which was called:
# once (5µs+0s) by Foswiki::Prefs::TopicRAM::BEGIN@22 at line 29 | ||||
25 | 1 | 9µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
26 | require locale; | ||||
27 | import locale(); | ||||
28 | } | ||||
29 | 1 | 326µs | 1 | 5µs | } # spent 5µs making 1 call to Foswiki::Prefs::Parser::BEGIN@24 |
30 | |||||
31 | =begin TML | ||||
32 | |||||
33 | ---++ StaticFunction parse( $topicObject, $prefs ) | ||||
34 | |||||
35 | Parse settings from the topic and add them to the preferences in $prefs | ||||
36 | |||||
37 | =cut | ||||
38 | |||||
39 | # spent 45.0ms (6.95+38.1) within Foswiki::Prefs::Parser::parse which was called 29 times, avg 1.55ms/call:
# 29 times (6.95ms+38.1ms) by Foswiki::Prefs::TopicRAM::new at line 38 of /var/www/foswikidev/core/lib/Foswiki/Prefs/TopicRAM.pm, avg 1.55ms/call | ||||
40 | 29 | 14µs | my ( $topicObject, $prefs ) = @_; | ||
41 | |||||
42 | # Process text first | ||||
43 | 29 | 7µs | my $key = ''; | ||
44 | 29 | 5µs | my $value = ''; | ||
45 | 29 | 4µs | my $type; | ||
46 | 29 | 44µs | 29 | 34.1ms | my $text = $topicObject->text(); # spent 34.1ms making 29 calls to Foswiki::Meta::text, avg 1.18ms/call |
47 | 29 | 5µs | $text = '' unless defined $text; | ||
48 | |||||
49 | 29 | 1.53ms | foreach ( split( "\n", $text ) ) { | ||
50 | 3000 | 3.35ms | if (m/$Foswiki::regex{setVarRegex}/s) { | ||
51 | 413 | 246µs | 182 | 1.56ms | if ( defined $type ) { # spent 1.56ms making 182 calls to Foswiki::Prefs::TopicRAM::insert, avg 9µs/call |
52 | $prefs->insert( $type, $key, $value ); | ||||
53 | } | ||||
54 | 413 | 258µs | $type = $1; | ||
55 | 413 | 96µs | $key = $2; | ||
56 | 413 | 207µs | $value = ( defined $3 ) ? $3 : ''; | ||
57 | } | ||||
58 | elsif ( defined $type ) { | ||||
59 | 233 | 263µs | if ( /^( |\t)+ *[^\s]/ && !/$Foswiki::regex{bulletRegex}/ ) { | ||
60 | |||||
61 | # follow up line, extending value | ||||
62 | $value .= "\n" . $_; | ||||
63 | } | ||||
64 | else { | ||||
65 | 231 | 265µs | 231 | 2.23ms | $prefs->insert( $type, $key, $value ); # spent 2.23ms making 231 calls to Foswiki::Prefs::TopicRAM::insert, avg 10µs/call |
66 | 231 | 74µs | undef $type; | ||
67 | } | ||||
68 | } | ||||
69 | } | ||||
70 | 29 | 6µs | if ( defined $type ) { | ||
71 | $prefs->insert( $type, $key, $value ); | ||||
72 | } | ||||
73 | |||||
74 | # Now process PREFERENCEs | ||||
75 | 29 | 52µs | 29 | 86µs | my @fields = $topicObject->find('PREFERENCE'); # spent 86µs making 29 calls to Foswiki::Meta::find, avg 3µs/call |
76 | 29 | 23µs | foreach my $field (@fields) { | ||
77 | 1 | 900ns | my $type = $field->{type} || 'Set'; | ||
78 | 1 | 500ns | my $value = $field->{value}; | ||
79 | 1 | 500ns | my $name = $field->{name}; | ||
80 | 1 | 2µs | 1 | 10µs | $prefs->insert( $type, $name, $value ); # spent 10µs making 1 call to Foswiki::Prefs::TopicRAM::insert |
81 | } | ||||
82 | |||||
83 | # Note that the use of the "S" attribute to support settings in | ||||
84 | # form fields has been deprecated. | ||||
85 | 29 | 37µs | 29 | 56µs | my $form = $topicObject->get('FORM'); # spent 56µs making 29 calls to Foswiki::Meta::get, avg 2µs/call |
86 | 29 | 60µs | if ($form) { | ||
87 | my @fields = $topicObject->find('FIELD'); | ||||
88 | foreach my $field (@fields) { | ||||
89 | my $attributes = $field->{attributes}; | ||||
90 | if ( $attributes && $attributes =~ m/S/ ) { | ||||
91 | my $value = $field->{value}; | ||||
92 | my $name = $field->{name}; | ||||
93 | $prefs->insert( 'Set', 'FORM_' . $name, $value ); | ||||
94 | $prefs->insert( 'Set', $name, $value ); | ||||
95 | } | ||||
96 | } | ||||
97 | } | ||||
98 | } | ||||
99 | |||||
100 | 1 | 2µs | 1; | ||
101 | __END__ |