line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::PackIndex; |
2
|
4
|
|
|
4
|
|
16
|
use Moose; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
21
|
|
3
|
4
|
|
|
4
|
|
10595
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
37
|
|
4
|
4
|
|
|
4
|
|
8730
|
use IO::File; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
547
|
|
5
|
4
|
|
|
4
|
|
19
|
use namespace::autoclean; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
31
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'filename' => |
8
|
|
|
|
|
|
|
( is => 'ro', isa => 'Path::Class::File', required => 1, coerce => 1 ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'fh' => ( is => 'rw', isa => 'IO::File', required => 0 ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'offsets' => |
13
|
|
|
|
|
|
|
( is => 'rw', isa => 'ArrayRef[Int]', required => 0, auto_deref => 1, ); |
14
|
|
|
|
|
|
|
has 'size' => ( is => 'rw', isa => 'Int', required => 0 ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $FanOutCount = 256; |
17
|
|
|
|
|
|
|
my $SHA1Size = 20; |
18
|
|
|
|
|
|
|
my $IdxOffsetSize = 4; |
19
|
|
|
|
|
|
|
my $OffsetSize = 4; |
20
|
|
|
|
|
|
|
my $CrcSize = 4; |
21
|
|
|
|
|
|
|
my $OffsetStart = $FanOutCount * $IdxOffsetSize; |
22
|
|
|
|
|
|
|
my $SHA1Start = $OffsetStart + $OffsetSize; |
23
|
|
|
|
|
|
|
my $EntrySize = $OffsetSize + $SHA1Size; |
24
|
|
|
|
|
|
|
my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILD { |
27
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
28
|
3
|
|
|
|
|
94
|
my $filename = $self->filename; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
33
|
|
|
18
|
my $fh = IO::File->new($filename) || confess($!); |
31
|
3
|
|
|
|
|
303
|
$self->fh($fh); |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
6
|
my @offsets = (0); |
34
|
3
|
|
|
|
|
18
|
$fh->seek( $self->global_offset, 0 ); |
35
|
3
|
|
|
|
|
24
|
foreach my $i ( 0 .. $FanOutCount - 1 ) { |
36
|
768
|
|
|
|
|
906
|
$fh->read( my $data, $IdxOffsetSize ); |
37
|
768
|
|
|
|
|
1899
|
my $offset = unpack( 'N', $data ); |
38
|
768
|
50
|
|
|
|
897
|
confess("pack has discontinuous index") if $offset < $offsets[-1]; |
39
|
768
|
|
|
|
|
642
|
push @offsets, $offset; |
40
|
|
|
|
|
|
|
} |
41
|
3
|
|
|
|
|
109
|
$self->offsets( \@offsets ); |
42
|
3
|
|
|
|
|
94
|
$self->size( $offsets[-1] ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
46
|
|
|
|
|
|
|
|