line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Zoom::MappedStream; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
24
|
use strictures 1; |
|
6
|
|
|
|
|
37
|
|
|
6
|
|
|
|
|
162
|
|
4
|
6
|
|
|
6
|
|
553
|
use base qw(HTML::Zoom::StreamBase); |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
1296
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
18
|
|
|
18
|
0
|
27
|
my ($class, $args) = @_; |
8
|
18
|
|
|
|
|
152
|
bless({ |
9
|
|
|
|
|
|
|
_source => $args->{source}, _mapper => $args->{mapper}, |
10
|
|
|
|
|
|
|
_zconfig => $args->{zconfig} |
11
|
|
|
|
|
|
|
}, $class); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _next { |
15
|
62
|
|
|
62
|
|
58
|
my ($self, $am_peek) = @_; |
16
|
62
|
50
|
|
|
|
120
|
return unless $self->{_source}; |
17
|
|
|
|
|
|
|
# If we were aiming for a "true" perl-like map then we should |
18
|
|
|
|
|
|
|
# elegantly handle the case where the map function returns 0 events |
19
|
|
|
|
|
|
|
# and the case where it returns >1 - if you're reading this comment |
20
|
|
|
|
|
|
|
# because you wanted it to do that, now would be the time to fix it :) |
21
|
62
|
50
|
|
|
|
68
|
if (my ($next) = $self->{_source}->${\($am_peek ? 'peek' : 'next')}) { |
|
62
|
100
|
|
|
|
172
|
|
22
|
44
|
50
|
|
|
|
200
|
$self->{_peeked_from} = $next if $am_peek; |
23
|
44
|
|
|
|
|
51
|
local $_ = $next; |
24
|
44
|
|
|
|
|
101
|
return $self->{_mapper}->($next); |
25
|
|
|
|
|
|
|
} |
26
|
18
|
|
|
|
|
64
|
delete $self->{_source}; |
27
|
|
|
|
|
|
|
return |
28
|
18
|
|
|
|
|
51
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |