line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Stream::Buffered; |
2
|
2
|
|
|
2
|
|
227871
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
90
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
6452
|
use FileHandle; # for seek etc. |
|
2
|
|
|
|
|
54535
|
|
|
2
|
|
|
|
|
14
|
|
6
|
2
|
|
|
2
|
|
111173
|
use Stream::Buffered::Auto; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
231
|
|
7
|
2
|
|
|
2
|
|
42259
|
use Stream::Buffered::File; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
169
|
|
8
|
2
|
|
|
2
|
|
90415
|
use Stream::Buffered::PerlIO; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
877
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.03; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $MaxMemoryBufferSize = 1024 * 1024; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
6
|
|
|
6
|
0
|
2783
|
my($class, $length) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# $MaxMemoryBufferSize = 0 -> Always temp file |
18
|
|
|
|
|
|
|
# $MaxMemoryBufferSize = -1 -> Always PerlIO |
19
|
6
|
|
|
|
|
13
|
my $backend; |
20
|
6
|
50
|
|
|
|
38
|
if ($MaxMemoryBufferSize < 0) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
$backend = "PerlIO"; |
22
|
|
|
|
|
|
|
} elsif ($MaxMemoryBufferSize == 0) { |
23
|
2
|
|
|
|
|
5
|
$backend = "File"; |
24
|
|
|
|
|
|
|
} elsif (!$length) { |
25
|
2
|
|
|
|
|
4
|
$backend = "Auto"; |
26
|
|
|
|
|
|
|
} elsif ($length > $MaxMemoryBufferSize) { |
27
|
0
|
|
|
|
|
0
|
$backend = "File"; |
28
|
|
|
|
|
|
|
} else { |
29
|
2
|
|
|
|
|
4
|
$backend = "PerlIO"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
|
|
52
|
$class->create($backend, $length, $MaxMemoryBufferSize); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub create { |
36
|
10
|
|
|
10
|
0
|
21
|
my($class, $backend, $length, $max) = @_; |
37
|
10
|
|
|
|
|
88
|
(__PACKAGE__ . "::$backend")->new($length, $max); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub print; |
41
|
|
|
|
|
|
|
sub rewind; |
42
|
|
|
|
|
|
|
sub size; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |