Filename | /var/www/foswiki11/lib/Foswiki/Query/OP_where.pm |
Statements | Executed 14 statements in 469µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 1 | 1 | 49µs | 97µs | new | Foswiki::Query::OP_where::
1 | 1 | 1 | 19µs | 37µs | BEGIN@11 | Foswiki::Query::OP_where::
1 | 1 | 1 | 12µs | 18µs | BEGIN@12 | Foswiki::Query::OP_where::
1 | 1 | 1 | 5µs | 5µs | BEGIN@14 | Foswiki::Query::OP_where::
0 | 0 | 0 | 0s | 0s | evaluate | Foswiki::Query::OP_where::
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_where | ||||
6 | |||||
7 | =cut | ||||
8 | |||||
9 | package Foswiki::Query::OP_where; | ||||
10 | |||||
11 | 2 | 36µs | 2 | 54µs | # spent 37µs (19+18) within Foswiki::Query::OP_where::BEGIN@11 which was called:
# once (19µs+18µs) by Foswiki::Query::Parser::new at line 11 # spent 37µs making 1 call to Foswiki::Query::OP_where::BEGIN@11
# spent 18µs making 1 call to strict::import |
12 | 2 | 38µs | 2 | 25µs | # spent 18µs (12+7) within Foswiki::Query::OP_where::BEGIN@12 which was called:
# once (12µs+7µs) by Foswiki::Query::Parser::new at line 12 # spent 18µs making 1 call to Foswiki::Query::OP_where::BEGIN@12
# spent 7µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 332µs | 1 | 5µs | # spent 5µs within Foswiki::Query::OP_where::BEGIN@14 which was called:
# once (5µs+0s) by Foswiki::Query::Parser::new at line 14 # spent 5µs making 1 call to Foswiki::Query::OP_where::BEGIN@14 |
15 | 1 | 10µs | our @ISA = ('Foswiki::Query::BinaryOP'); | ||
16 | |||||
17 | # spent 97µs (49+48) within Foswiki::Query::OP_where::new which was called 3 times, avg 32µs/call:
# 3 times (49µs+48µs) by Foswiki::Query::Parser::new at line 47 of /var/www/foswiki11/lib/Foswiki/Query/Parser.pm, avg 32µs/call | ||||
18 | 3 | 2µs | my $class = shift; | ||
19 | 3 | 46µs | 3 | 48µs | return $class->SUPER::new( name => '[', close => ']', prec => 800 ); # spent 48µs making 3 calls to Foswiki::Query::BinaryOP::new, avg 16µs/call |
20 | } | ||||
21 | |||||
22 | sub evaluate { | ||||
23 | my $this = shift; | ||||
24 | my $node = shift; | ||||
25 | my %domain = @_; | ||||
26 | my $a = $node->{params}[0]; | ||||
27 | my $lval = $a->evaluate(@_); | ||||
28 | my $b = $node->{params}[1]; | ||||
29 | |||||
30 | # Special case; integer index responds with array el at that | ||||
31 | # index. | ||||
32 | if ( $b->{op} == $Foswiki::Infix::Node::NUMBER ) { | ||||
33 | if ( ref($lval) eq 'ARRAY' ) { | ||||
34 | return $lval->[ int( $b->{params}[0] ) ]; | ||||
35 | } | ||||
36 | if ( defined($lval) && 0 == int( $b->{params}[0] ) ) { | ||||
37 | return $lval; | ||||
38 | } | ||||
39 | return []; | ||||
40 | } | ||||
41 | |||||
42 | # Otherwise evaluate the inner query | ||||
43 | if ( ref($lval) eq 'ARRAY' ) { | ||||
44 | my @res; | ||||
45 | foreach my $el (@$lval) { | ||||
46 | if ( $b->evaluate( data => $el, tom => $domain{tom} ) ) { | ||||
47 | push( @res, $el ); | ||||
48 | } | ||||
49 | } | ||||
50 | return unless scalar(@res); | ||||
51 | return \@res; | ||||
52 | } | ||||
53 | else { | ||||
54 | return $b->evaluate( data => $lval, tom => $domain{tom} ) ? $lval : []; | ||||
55 | } | ||||
56 | } | ||||
57 | |||||
58 | 1 | 4µs | 1; | ||
59 | __END__ |