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

Filename/var/www/foswiki11/lib/Foswiki/If/OP_allows.pm
StatementsExecuted 14 statements in 562µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11125µs52µsFoswiki::If::OP_allows::::newFoswiki::If::OP_allows::new
11122µs40µsFoswiki::If::OP_allows::::BEGIN@11Foswiki::If::OP_allows::BEGIN@11
11113µs20µsFoswiki::If::OP_allows::::BEGIN@12Foswiki::If::OP_allows::BEGIN@12
11112µs32µsFoswiki::If::OP_allows::::BEGIN@17Foswiki::If::OP_allows::BEGIN@17
1115µs5µsFoswiki::If::OP_allows::::BEGIN@18Foswiki::If::OP_allows::BEGIN@18
1115µs5µsFoswiki::If::OP_allows::::BEGIN@14Foswiki::If::OP_allows::BEGIN@14
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
6
7=cut
8
9package Foswiki::If::OP_allows;
10
11243µs259µs
# spent 40µs (22+18) within Foswiki::If::OP_allows::BEGIN@11 which was called: # once (22µs+18µs) by Foswiki::If::Parser::new at line 11
use strict;
# spent 40µs making 1 call to Foswiki::If::OP_allows::BEGIN@11 # spent 18µs making 1 call to strict::import
12235µs227µs
# spent 20µs (13+7) within Foswiki::If::OP_allows::BEGIN@12 which was called: # once (13µs+7µs) by Foswiki::If::Parser::new at line 12
use warnings;
# spent 20µs making 1 call to Foswiki::If::OP_allows::BEGIN@12 # spent 7µs making 1 call to warnings::import
13
14245µs15µs
# spent 5µs within Foswiki::If::OP_allows::BEGIN@14 which was called: # once (5µs+0s) by Foswiki::If::Parser::new at line 14
use Foswiki::Query::BinaryOP ();
# spent 5µs making 1 call to Foswiki::If::OP_allows::BEGIN@14
1519µsour @ISA = ('Foswiki::Query::BinaryOP');
16
17233µs251µs
# spent 32µs (12+19) within Foswiki::If::OP_allows::BEGIN@17 which was called: # once (12µs+19µs) by Foswiki::If::Parser::new at line 17
use Assert;
# spent 32µs making 1 call to Foswiki::If::OP_allows::BEGIN@17 # spent 19µs making 1 call to Assert::import
182369µs15µs
# spent 5µs within Foswiki::If::OP_allows::BEGIN@18 which was called: # once (5µs+0s) by Foswiki::If::Parser::new at line 18
use Foswiki::Meta ();
# spent 5µs making 1 call to Foswiki::If::OP_allows::BEGIN@18
19
20
# spent 52µs (25+27) within Foswiki::If::OP_allows::new which was called: # once (25µs+27µs) by Foswiki::If::Parser::new at line 31 of /var/www/foswiki11/lib/Foswiki/If/Parser.pm
sub new {
211700ns my $class = shift;
22124µs127µs return $class->SUPER::new( name => 'allows', prec => 600 );
# spent 27µs making 1 call to Foswiki::Query::BinaryOP::new
23}
24
25sub evaluate {
26 my $this = shift;
27 my $node = shift;
28 my $a = $node->{params}->[0]; # topic name (string)
29 my $b = $node->{params}->[1]; # access mode (string)
30 my $mode = $b->_evaluate(@_) || 'view';
31 my %domain = @_;
32 my $session = $domain{tom}->session;
33 throw Error::Simple(
34 'No context in which to evaluate "' . $a->stringify() . '"' )
35 unless $session;
36
37 my $str = $a->evaluate(@_);
38 return 0 unless $str;
39
40 my ( $web, $topic ) =
41 $session->normalizeWebTopicName( $session->{webName}, $str );
42
43 my $ok = 0;
44
45 # Try for an existing topic first.
46 if ( $session->topicExists( $web, $topic ) ) {
47
48 my $topicObject = Foswiki::Meta->new( $session, $web, $topic );
49 $ok = $topicObject->haveAccess($mode);
50 }
51
52 # Not an existing web.topic name, see if the string on its own
53 # is a web name
54 elsif ( $session->webExists($str) ) {
55 my $webObject = Foswiki::Meta->new( $session, $str );
56 $ok = $webObject->haveAccess($mode);
57 }
58
59 # Not an existing web.topic or a web on it's own; maybe it's
60 # web.topic for an existing web but non-existing topic
61 elsif ( $session->webExists($web) ) {
62 my $webObject = Foswiki::Meta->new( $session, $web );
63 $ok = $webObject->haveAccess($mode);
64 }
65 else {
66 $ok = 0;
67 }
68 return $ok ? 1 : 0;
69}
70
7114µs1;
72__END__