line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package WWW::Kickstarter::Iterator; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
5
|
no autovivification; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
|
|
sub _done { () } |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
1
|
|
my ($class, $generator, $buf) = @_; |
14
|
0
|
|
|
|
|
|
my $self = bless({}, $class); |
15
|
0
|
|
0
|
|
|
|
$self->{generator} = $generator || \&_done; |
16
|
0
|
|
0
|
|
|
|
$self->{buf } = $buf || []; |
17
|
0
|
|
|
|
|
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get { |
22
|
0
|
|
|
0
|
1
|
|
my ($self, $n) = @_; |
23
|
0
|
|
0
|
|
|
|
$n ||= 1; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $buf = $self->{buf}; |
26
|
0
|
|
|
|
|
|
while (@$buf < $n) { |
27
|
|
|
|
|
|
|
my @add = $self->{generator}->() |
28
|
0
|
0
|
|
|
|
|
or do { |
29
|
0
|
|
|
|
|
|
$self->{generator} = \&_done; |
30
|
0
|
|
|
|
|
|
last; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
push @$buf, @add; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return splice(@$buf, 0, $n); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_rest { |
41
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $buf = $self->{buf}; |
44
|
0
|
|
|
|
|
|
while (my @add = $self->{generator}->()) { |
45
|
0
|
|
|
|
|
|
push @$buf, @add; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->{generator} = \&_done; |
49
|
0
|
|
|
|
|
|
return splice(@$buf, 0, $#$buf); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_chunk { |
54
|
0
|
|
|
0
|
1
|
|
my ($self, $min) = @_; |
55
|
0
|
|
0
|
|
|
|
$min ||= 1; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $buf = $self->{buf}; |
58
|
0
|
|
|
|
|
|
while (@$buf < $min) { |
59
|
|
|
|
|
|
|
my @add = $self->{generator}->() |
60
|
0
|
0
|
|
|
|
|
or do { |
61
|
0
|
|
|
|
|
|
$self->{generator} = \&_done; |
62
|
0
|
|
|
|
|
|
last; |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
push @$buf, @add; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return splice(@$buf, 0, $#$buf); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |