line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::PackIndex::Version1; |
2
|
4
|
|
|
4
|
|
17
|
use Moose; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
25
|
|
3
|
4
|
|
|
4
|
|
18961
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
28
|
|
4
|
4
|
|
|
4
|
|
8992
|
use namespace::autoclean; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'Git::PurePerl::PackIndex'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $FanOutCount = 256; |
9
|
|
|
|
|
|
|
my $SHA1Size = 20; |
10
|
|
|
|
|
|
|
my $IdxOffsetSize = 4; |
11
|
|
|
|
|
|
|
my $OffsetSize = 4; |
12
|
|
|
|
|
|
|
my $CrcSize = 4; |
13
|
|
|
|
|
|
|
my $OffsetStart = $FanOutCount * $IdxOffsetSize; |
14
|
|
|
|
|
|
|
my $SHA1Start = $OffsetStart + $OffsetSize; |
15
|
|
|
|
|
|
|
my $EntrySize = $OffsetSize + $SHA1Size; |
16
|
|
|
|
|
|
|
my $EntrySizeV2 = $SHA1Size + $CrcSize + $OffsetSize; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub global_offset { |
19
|
2
|
|
|
2
|
0
|
11
|
return 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub all_sha1s { |
23
|
4
|
|
|
4
|
0
|
8
|
my ( $self, $want_sha1 ) = @_; |
24
|
4
|
|
|
|
|
91
|
my $fh = $self->fh; |
25
|
4
|
|
|
|
|
3
|
my @sha1s; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
5
|
my $pos = $OffsetStart; |
28
|
4
|
50
|
|
|
|
14
|
$fh->seek( $pos, 0 ) || die $!; |
29
|
4
|
|
|
|
|
124
|
foreach my $i ( 1 .. $self->size ) { |
30
|
1522
|
50
|
|
|
|
1846
|
$fh->read( my $data, $OffsetSize ) || die $!; |
31
|
1522
|
|
|
|
|
4987
|
my $offset = unpack( 'N', $data ); |
32
|
1522
|
50
|
|
|
|
1888
|
$fh->read( $data, $SHA1Size ) || die $!; |
33
|
1522
|
|
|
|
|
4954
|
my $sha1 = unpack( 'H*', $data ); |
34
|
1522
|
|
|
|
|
1193
|
push @sha1s, $sha1; |
35
|
1522
|
|
|
|
|
1212
|
$pos += $EntrySize; |
36
|
|
|
|
|
|
|
} |
37
|
4
|
|
|
|
|
321
|
return @sha1s; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_object_offset { |
41
|
2315
|
|
|
2315
|
0
|
2333
|
my ( $self, $want_sha1 ) = @_; |
42
|
2315
|
|
|
|
|
52113
|
my @offsets = $self->offsets; |
43
|
2315
|
|
|
|
|
60772
|
my $fh = $self->fh; |
44
|
|
|
|
|
|
|
|
45
|
2315
|
|
|
|
|
6343
|
my $slot = unpack( 'C', pack( 'H*', $want_sha1 ) ); |
46
|
2315
|
50
|
|
|
|
3817
|
return unless defined $slot; |
47
|
|
|
|
|
|
|
|
48
|
2315
|
|
|
|
|
3249
|
my ( $first, $last ) = @offsets[ $slot, $slot + 1 ]; |
49
|
|
|
|
|
|
|
|
50
|
2315
|
|
|
|
|
3780
|
while ( $first < $last ) { |
51
|
4299
|
|
|
|
|
5393
|
my $mid = int( ( $first + $last ) / 2 ); |
52
|
4299
|
50
|
|
|
|
9599
|
$fh->seek( $SHA1Start + $mid * $EntrySize, 0 ) || die $!; |
53
|
4299
|
50
|
|
|
|
25517
|
$fh->read( my $data, $SHA1Size ) || die $!; |
54
|
4299
|
|
|
|
|
31694
|
my $midsha1 = unpack( 'H*', $data ); |
55
|
4299
|
100
|
|
|
|
7918
|
if ( $midsha1 lt $want_sha1 ) { |
|
|
100
|
|
|
|
|
|
56
|
765
|
|
|
|
|
1403
|
$first = $mid + 1; |
57
|
|
|
|
|
|
|
} elsif ( $midsha1 gt $want_sha1 ) { |
58
|
1219
|
|
|
|
|
2049
|
$last = $mid; |
59
|
|
|
|
|
|
|
} else { |
60
|
2315
|
|
|
|
|
2096
|
my $pos = $OffsetStart + $mid * $EntrySize; |
61
|
2315
|
50
|
|
|
|
3904
|
$fh->seek( $pos, 0 ) || die $!; |
62
|
2315
|
50
|
|
|
|
10842
|
$fh->read( my $data, $OffsetSize ) || die $!; |
63
|
2315
|
|
|
|
|
12465
|
my $offset = unpack( 'N', $data ); |
64
|
2315
|
|
|
|
|
13464
|
return $offset; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
72
|
|
|
|
|
|
|
|