Filename | /var/www/foswiki11/lib/Foswiki/Query/OP_ref.pm |
Statements | Executed 22 statements in 901µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 1 | 1 | 56µs | 106µs | new | Foswiki::Query::OP_ref::
1 | 1 | 1 | 24µs | 42µs | BEGIN@11 | Foswiki::Query::OP_ref::
1 | 1 | 1 | 17µs | 32µs | BEGIN@73 | Foswiki::Query::OP_ref::
1 | 1 | 1 | 15µs | 33µs | BEGIN@75 | Foswiki::Query::OP_ref::
1 | 1 | 1 | 14µs | 38µs | BEGIN@17 | Foswiki::Query::OP_ref::
1 | 1 | 1 | 13µs | 21µs | BEGIN@12 | Foswiki::Query::OP_ref::
1 | 1 | 1 | 13µs | 166µs | BEGIN@16 | Foswiki::Query::OP_ref::
1 | 1 | 1 | 6µs | 6µs | BEGIN@13 | Foswiki::Query::OP_ref::
0 | 0 | 0 | 0s | 0s | __ANON__[:60] | Foswiki::Query::OP_ref::
0 | 0 | 0 | 0s | 0s | __ANON__[:63] | Foswiki::Query::OP_ref::
0 | 0 | 0 | 0s | 0s | evaluate | Foswiki::Query::OP_ref::
0 | 0 | 0 | 0s | 0s | evaluatesToConstant | Foswiki::Query::OP_ref::
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::Query::OP_ref | ||||
6 | |||||
7 | =cut | ||||
8 | |||||
9 | package Foswiki::Query::OP_ref; | ||||
10 | |||||
11 | 2 | 41µs | 2 | 61µs | # spent 42µs (24+19) within Foswiki::Query::OP_ref::BEGIN@11 which was called:
# once (24µs+19µs) by Foswiki::Query::Parser::new at line 11 # spent 42µs making 1 call to Foswiki::Query::OP_ref::BEGIN@11
# spent 19µs making 1 call to strict::import |
12 | 2 | 34µs | 2 | 29µs | # spent 21µs (13+8) within Foswiki::Query::OP_ref::BEGIN@12 which was called:
# once (13µs+8µs) by Foswiki::Query::Parser::new at line 12 # spent 21µs making 1 call to Foswiki::Query::OP_ref::BEGIN@12
# spent 8µs making 1 call to warnings::import |
13 | 2 | 71µs | 1 | 6µs | # spent 6µs within Foswiki::Query::OP_ref::BEGIN@13 which was called:
# once (6µs+0s) by Foswiki::Query::Parser::new at line 13 # spent 6µs making 1 call to Foswiki::Query::OP_ref::BEGIN@13 |
14 | 1 | 10µs | our @ISA = ('Foswiki::Query::BinaryOP'); | ||
15 | |||||
16 | 2 | 44µs | 2 | 320µs | # spent 166µs (13+153) within Foswiki::Query::OP_ref::BEGIN@16 which was called:
# once (13µs+153µs) by Foswiki::Query::Parser::new at line 16 # spent 166µs making 1 call to Foswiki::Query::OP_ref::BEGIN@16
# spent 153µs making 1 call to Error::import |
17 | 2 | 505µs | 2 | 62µs | # spent 38µs (14+24) within Foswiki::Query::OP_ref::BEGIN@17 which was called:
# once (14µs+24µs) by Foswiki::Query::Parser::new at line 17 # spent 38µs making 1 call to Foswiki::Query::OP_ref::BEGIN@17
# spent 24µs making 1 call to Assert::import |
18 | |||||
19 | # spent 106µs (56+50) within Foswiki::Query::OP_ref::new which was called 3 times, avg 35µs/call:
# 3 times (56µs+50µs) by Foswiki::Query::Parser::new at line 47 of /var/www/foswiki11/lib/Foswiki/Query/Parser.pm, avg 35µs/call | ||||
20 | 3 | 4µs | my $class = shift; | ||
21 | 3 | 43µs | 3 | 50µs | return $class->SUPER::new( name => '/', prec => 800 ); # spent 50µs making 3 calls to Foswiki::Query::BinaryOP::new, avg 17µs/call |
22 | } | ||||
23 | |||||
24 | sub evaluate { | ||||
25 | my $this = shift; | ||||
26 | my $pnode = shift; | ||||
27 | my %domain = @_; | ||||
28 | |||||
29 | eval "require $Foswiki::cfg{Store}{QueryAlgorithm}"; | ||||
30 | die $@ if $@; | ||||
31 | |||||
32 | my $a = $pnode->{params}[0]; | ||||
33 | my $node = $a->evaluate(@_); | ||||
34 | return unless defined $node; | ||||
35 | if ( ref($node) eq 'HASH' ) { | ||||
36 | return; | ||||
37 | } | ||||
38 | if ( !( ref($node) eq 'ARRAY' ) ) { | ||||
39 | $node = [$node]; | ||||
40 | } | ||||
41 | my @result; | ||||
42 | foreach my $v (@$node) { | ||||
43 | |||||
44 | # Has to be relative to the web of the topic we are querying | ||||
45 | my ( $w, $t ) = | ||||
46 | $Foswiki::Plugins::SESSION->normalizeWebTopicName( | ||||
47 | $Foswiki::Plugins::SESSION->{webName}, $v ); | ||||
48 | try { | ||||
49 | my $submeta = | ||||
50 | $Foswiki::cfg{Store}{QueryAlgorithm} | ||||
51 | ->getRefTopic( $domain{tom}, $w, $t ); | ||||
52 | my $b = $pnode->{params}[1]; | ||||
53 | my $res = $b->evaluate( tom => $submeta, data => $submeta ); | ||||
54 | if ( ref($res) eq 'ARRAY' ) { | ||||
55 | push( @result, @$res ); | ||||
56 | } | ||||
57 | else { | ||||
58 | push( @result, $res ); | ||||
59 | } | ||||
60 | } | ||||
61 | catch Error::Simple with { | ||||
62 | print STDERR "ERROR IN OP_ref: $_[0]->{-text}" if DEBUG; | ||||
63 | }; | ||||
64 | } | ||||
65 | return unless scalar(@result); | ||||
66 | return $result[0] if scalar(@result) == 1; | ||||
67 | return \@result; | ||||
68 | } | ||||
69 | |||||
70 | sub evaluatesToConstant { | ||||
71 | my $this = shift; | ||||
72 | my $node = shift; | ||||
73 | 2 | 70µs | 2 | 47µs | # spent 32µs (17+15) within Foswiki::Query::OP_ref::BEGIN@73 which was called:
# once (17µs+15µs) by Foswiki::Query::Parser::new at line 73 # spent 32µs making 1 call to Foswiki::Query::OP_ref::BEGIN@73
# spent 15µs making 1 call to warnings::unimport |
74 | return 1 if $node->{params}[0]->evaluatesToConstant(@_); | ||||
75 | 2 | 74µs | 2 | 51µs | # spent 33µs (15+18) within Foswiki::Query::OP_ref::BEGIN@75 which was called:
# once (15µs+18µs) by Foswiki::Query::Parser::new at line 75 # spent 33µs making 1 call to Foswiki::Query::OP_ref::BEGIN@75
# spent 18µs making 1 call to warnings::import |
76 | |||||
77 | # param[1] may contain non-constant terms, but that's OK because | ||||
78 | # they are evaluated relative to the (constant) param[0] | ||||
79 | return 0; | ||||
80 | } | ||||
81 | |||||
82 | 1 | 4µs | 1; | ||
83 | __END__ |