← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:11 2015

Filename/var/www/foswiki11/lib/Foswiki/Form/ListFieldDefinition.pm
StatementsExecuted 10 statements in 480µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs30µsFoswiki::Form::ListFieldDefinition::::BEGIN@14Foswiki::Form::ListFieldDefinition::BEGIN@14
1119µs23µsFoswiki::Form::ListFieldDefinition::::BEGIN@16Foswiki::Form::ListFieldDefinition::BEGIN@16
1119µs14µsFoswiki::Form::ListFieldDefinition::::BEGIN@15Foswiki::Form::ListFieldDefinition::BEGIN@15
1114µs4µsFoswiki::Form::ListFieldDefinition::::BEGIN@18Foswiki::Form::ListFieldDefinition::BEGIN@18
0000s0sFoswiki::Form::ListFieldDefinition::::finishFoswiki::Form::ListFieldDefinition::finish
0000s0sFoswiki::Form::ListFieldDefinition::::getOptionsFoswiki::Form::ListFieldDefinition::getOptions
Call graph for these subroutines as a Graphviz dot language file.
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::Form::ListFieldDefinition
6Form field definitions that accept lists of values in the field definition.
7This is different to being multi-valued, which means the field type
8can *store* multiple values.
9
10=cut
11
12package Foswiki::Form::ListFieldDefinition;
13
14228µs244µs
# spent 30µs (17+13) within Foswiki::Form::ListFieldDefinition::BEGIN@14 which was called: # once (17µs+13µs) by Foswiki::Form::BEGIN@43 at line 14
use strict;
# spent 30µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@14 # spent 13µs making 1 call to strict::import
15227µs220µs
# spent 14µs (9+5) within Foswiki::Form::ListFieldDefinition::BEGIN@15 which was called: # once (9µs+5µs) by Foswiki::Form::BEGIN@43 at line 15
use warnings;
# spent 14µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@15 # spent 5µs making 1 call to warnings::import
16225µs237µs
# spent 23µs (9+14) within Foswiki::Form::ListFieldDefinition::BEGIN@16 which was called: # once (9µs+14µs) by Foswiki::Form::BEGIN@43 at line 16
use Assert;
# spent 23µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@16 # spent 14µs making 1 call to Assert::import
17
182384µs14µs
# spent 4µs within Foswiki::Form::ListFieldDefinition::BEGIN@18 which was called: # once (4µs+0s) by Foswiki::Form::BEGIN@43 at line 18
use Foswiki::Form::FieldDefinition ();
# spent 4µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@18
19112µsour @ISA = ('Foswiki::Form::FieldDefinition');
20
21=begin TML
22
23---++ ObjectMethod finish()
24Break circular references.
25
26=cut
27
28# Note to developers; please undef *all* fields in the object explicitly,
29# whether they are references or not. That way this method is "golden
30# documentation" of the live fields in the object.
31sub finish {
32 my $this = shift;
33 $this->SUPER::finish();
34 undef $this->{_options};
35 undef $this->{_descriptions};
36}
37
38# PROTECTED - parse the {value} and extract a list of options.
39# Done lazily to avoid repeated topic reads.
40sub getOptions {
41
42 # $web and $topic are where the form definition lives
43 my $this = shift;
44
45 return $this->{_options} if $this->{_options};
46
47 my @vals = ();
48 my %descr = ();
49
50 @vals = split( /,/, $this->{value} );
51 if ( !scalar(@vals) ) {
52 my $topic = $this->{definingTopic} || $this->{name};
53 my $session = $this->{session};
54
55 my ( $fieldWeb, $fieldTopic ) =
56 $session->normalizeWebTopicName( $this->{web}, $topic );
57
58 $fieldWeb = Foswiki::Sandbox::untaint( $fieldWeb,
59 \&Foswiki::Sandbox::validateWebName );
60 $fieldTopic = Foswiki::Sandbox::untaint( $fieldTopic,
61 \&Foswiki::Sandbox::validateTopicName );
62
63 if ( $session->topicExists( $fieldWeb, $fieldTopic ) ) {
64
65 my $meta = Foswiki::Meta->load( $session, $fieldWeb, $fieldTopic );
66 next unless $meta->haveAccess('VIEW');
67
68 # Process SEARCHES for Lists
69 my $text = $meta->expandMacros( $meta->text() );
70
71 # SMELL: yet another table parser
72 my $inBlock = 0;
73 foreach ( split( /\r?\n/, $text ) ) {
74 if (/^\s*\|\s*\*Name\*\s*\|/) {
75 $inBlock = 1;
76 }
77 elsif (/^\s*\|\s*([^|]*?)\s*\|(?:\s*([^|]*?)\s*\|)?/) {
78 if ($inBlock) {
79 push( @vals, TAINT($1) );
80 $descr{$1} = $2 if defined $2;
81 }
82 }
83 else {
84 $inBlock = 0;
85 }
86 }
87 }
88 }
89 @vals = map { $_ =~ s/^\s*(.*)\s*$/$1/; $_; } @vals;
90
91 $this->{_options} = \@vals;
92 $this->{_descriptions} = \%descr;
93
94 return $this->{_options};
95}
96
9713µs1;
98__END__