← 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:27:21 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/If/OP_allows.pm
StatementsExecuted 14 statements in 733µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11134µs58µsFoswiki::If::OP_allows::::BEGIN@13Foswiki::If::OP_allows::BEGIN@13
11131µs46µsFoswiki::If::OP_allows::::newFoswiki::If::OP_allows::new
11124µs32µsFoswiki::If::OP_allows::::BEGIN@12Foswiki::If::OP_allows::BEGIN@12
11123µs63µsFoswiki::If::OP_allows::::BEGIN@18Foswiki::If::OP_allows::BEGIN@18
11110µs10µsFoswiki::If::OP_allows::::BEGIN@15Foswiki::If::OP_allows::BEGIN@15
1119µs9µsFoswiki::If::OP_allows::::BEGIN@19Foswiki::If::OP_allows::BEGIN@19
0000s0sFoswiki::If::OP_allows::::evaluateFoswiki::If::OP_allows::evaluate
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::If::OP_allows
6Test that the topic name on the LHS allows the access mode on the RHS.
7
8=cut
9
10package Foswiki::If::OP_allows;
11
12245µs239µs
# spent 32µs (24+7) within Foswiki::If::OP_allows::BEGIN@12 which was called: # once (24µs+7µs) by Foswiki::If::Parser::BEGIN@22 at line 12
use strict;
# spent 32µs making 1 call to Foswiki::If::OP_allows::BEGIN@12 # spent 7µs making 1 call to strict::import
13267µs283µs
# spent 58µs (34+24) within Foswiki::If::OP_allows::BEGIN@13 which was called: # once (34µs+24µs) by Foswiki::If::Parser::BEGIN@22 at line 13
use warnings;
# spent 58µs making 1 call to Foswiki::If::OP_allows::BEGIN@13 # spent 25µs making 1 call to warnings::import
14
15265µs110µs
# spent 10µs within Foswiki::If::OP_allows::BEGIN@15 which was called: # once (10µs+0s) by Foswiki::If::Parser::BEGIN@22 at line 15
use Foswiki::Query::OP ();
# spent 10µs making 1 call to Foswiki::If::OP_allows::BEGIN@15
16111µsour @ISA = ('Foswiki::Query::OP');
17
18243µs2103µs
# spent 63µs (23+40) within Foswiki::If::OP_allows::BEGIN@18 which was called: # once (23µs+40µs) by Foswiki::If::Parser::BEGIN@22 at line 18
use Assert;
# spent 63µs making 1 call to Foswiki::If::OP_allows::BEGIN@18 # spent 40µs making 1 call to Assert::import
192464µs19µs
# spent 9µs within Foswiki::If::OP_allows::BEGIN@19 which was called: # once (9µs+0s) by Foswiki::If::Parser::BEGIN@22 at line 19
use Foswiki::Meta ();
# spent 9µs making 1 call to Foswiki::If::OP_allows::BEGIN@19
20
21
# spent 46µs (31+14) within Foswiki::If::OP_allows::new which was called: # once (31µs+14µs) by Foswiki::If::Parser::new at line 42 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/If/Parser.pm
sub new {
2212µs my $class = shift;
23130µs114µs return $class->SUPER::new( arity => 2, name => 'allows', prec => 600 );
# spent 14µs making 1 call to Foswiki::Query::OP::new
24}
25
26sub evaluate {
27 my $this = shift;
28 my $node = shift;
29 my $a = $node->{params}->[0]; # topic name (string)
30 my $b = $node->{params}->[1]; # access mode (string)
31 my $mode = $b->_evaluate(@_) || 'view';
32 my %domain = @_;
33 my $session = $domain{tom}->session;
34 throw Error::Simple(
35 'No context in which to evaluate "' . $a->stringify() . '"' )
36 unless $session;
37
38 my $str = $a->evaluate(@_);
39 return 0 unless $str;
40
41 my ( $web, $topic ) =
42 $session->normalizeWebTopicName( $session->{webName}, $str );
43
44 my $ok = 0;
45
46 # Try for an existing topic first.
47 if ( $session->topicExists( $web, $topic ) ) {
48
49 my $topicObject = Foswiki::Meta->new( $session, $web, $topic );
50 $ok = $topicObject->haveAccess($mode);
51 }
52
53 # Not an existing web.topic name, see if the string on its own
54 # is a web name
55 elsif ( $session->webExists($str) ) {
56 my $webObject = Foswiki::Meta->new( $session, $str );
57 $ok = $webObject->haveAccess($mode);
58 }
59
60 # Not an existing web.topic or a web on it's own; maybe it's
61 # web.topic for an existing web but non-existing topic
62 elsif ( $session->webExists($web) ) {
63 my $webObject = Foswiki::Meta->new( $session, $web );
64 $ok = $webObject->haveAccess($mode);
65 }
66 else {
67 $ok = 0;
68 }
69 return $ok ? 1 : 0;
70}
71
7216µs1;
73__END__