← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:36 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Form/ListFieldDefinition.pm
StatementsExecuted 34 statements in 956µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
822154µs284µsFoswiki::Form::ListFieldDefinition::::finishFoswiki::Form::ListFieldDefinition::finish
11128µs36µsFoswiki::Form::ListFieldDefinition::::BEGIN@14Foswiki::Form::ListFieldDefinition::BEGIN@14
11121µs39µsFoswiki::Form::ListFieldDefinition::::BEGIN@15Foswiki::Form::ListFieldDefinition::BEGIN@15
11117µs55µsFoswiki::Form::ListFieldDefinition::::BEGIN@16Foswiki::Form::ListFieldDefinition::BEGIN@16
11110µs10µsFoswiki::Form::ListFieldDefinition::::BEGIN@18Foswiki::Form::ListFieldDefinition::BEGIN@18
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
14246µs243µs
# spent 36µs (28+8) within Foswiki::Form::ListFieldDefinition::BEGIN@14 which was called: # once (28µs+8µs) by Foswiki::Form::BEGIN@43 at line 14
use strict;
# spent 36µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@14 # spent 8µs making 1 call to strict::import
15244µs257µs
# spent 39µs (21+18) within Foswiki::Form::ListFieldDefinition::BEGIN@15 which was called: # once (21µs+18µs) by Foswiki::Form::BEGIN@43 at line 15
use warnings;
# spent 39µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@15 # spent 18µs making 1 call to warnings::import
16270µs293µs
# spent 55µs (17+38) within Foswiki::Form::ListFieldDefinition::BEGIN@16 which was called: # once (17µs+38µs) by Foswiki::Form::BEGIN@43 at line 16
use Assert;
# spent 55µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@16 # spent 38µs making 1 call to Assert::import
17
182629µs110µs
# spent 10µs within Foswiki::Form::ListFieldDefinition::BEGIN@18 which was called: # once (10µs+0s) by Foswiki::Form::BEGIN@43 at line 18
use Foswiki::Form::FieldDefinition ();
# spent 10µs making 1 call to Foswiki::Form::ListFieldDefinition::BEGIN@18
19116µ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.
31
# spent 284µs (154+130) within Foswiki::Form::ListFieldDefinition::finish which was called 8 times, avg 35µs/call: # 4 times (97µs+61µs) by Foswiki::Form::finish at line 151 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Form.pm, avg 40µs/call # 4 times (57µs+69µs) by Foswiki::Form::Select::finish at line 86 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Form/Select.pm, avg 31µs/call
sub finish {
3224146µs my $this = shift;
338130µs $this->SUPER::finish();
# spent 130µs making 8 calls to Foswiki::Form::FieldDefinition::finish, avg 16µs/call
34 undef $this->{_options};
35}
36
37# PROTECTED - parse the {value} and extract a list of options.
38# Done lazily to avoid repeated topic reads.
39sub getOptions {
40
41 # $web and $topic are where the form definition lives
42 my $this = shift;
43
44 return $this->{_options} if $this->{_options};
45
46 my @vals = ();
47
48 @vals = split( /,/, $this->{value} );
49 if ( !scalar(@vals) ) {
50 my $topic = $this->{definingTopic} || $this->{name};
51 my $session = $this->{session};
52
53 my ( $fieldWeb, $fieldTopic ) =
54 $session->normalizeWebTopicName( $this->{web}, $topic );
55
56 $fieldWeb = Foswiki::Sandbox::untaint( $fieldWeb,
57 \&Foswiki::Sandbox::validateWebName );
58 $fieldTopic = Foswiki::Sandbox::untaint( $fieldTopic,
59 \&Foswiki::Sandbox::validateTopicName );
60
61 if ( $session->topicExists( $fieldWeb, $fieldTopic ) ) {
62
63 my $meta = Foswiki::Meta->load( $session, $fieldWeb, $fieldTopic );
64 next unless $meta->haveAccess('VIEW');
65
66 # Process SEARCHES for Lists
67 my $text = $meta->expandMacros( $meta->text() );
68
69 # SMELL: yet another table parser
70 my $inBlock = 0;
71 foreach ( split( /\r?\n/, $text ) ) {
72 if (/^\s*\|\s*\*Name\*\s*\|/) {
73 $inBlock = 1;
74 }
75 elsif (/^\s*\|\s*([^|]*?)\s*\|/) {
76 push( @vals, TAINT($1) ) if ($inBlock);
77 }
78 else {
79 $inBlock = 0;
80 }
81 }
82 }
83 }
84 @vals = map { $_ =~ s/^\s*(.*)\s*$/$1/; $_; } @vals;
85
86 $this->{_options} = \@vals;
87
88 return $this->{_options};
89}
90
9116µs1;
92__END__