line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::PackIndex::Version1; |
2
|
4
|
|
|
4
|
|
20
|
use Moose; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
43
|
|
3
|
4
|
|
|
4
|
|
19677
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
33
|
|
4
|
4
|
|
|
4
|
|
8751
|
use namespace::autoclean; |
|
4
|
|
|
|
|
8
|
|
|
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
|
17
|
return 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub all_sha1s { |
23
|
4
|
|
|
4
|
0
|
6
|
my ( $self, $want_sha1 ) = @_; |
24
|
4
|
|
|
|
|
102
|
my $fh = $self->fh; |
25
|
4
|
|
|
|
|
8
|
my @sha1s; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
5
|
my $pos = $OffsetStart; |
28
|
4
|
50
|
|
|
|
17
|
$fh->seek( $pos, 0 ) || die $!; |
29
|
4
|
|
|
|
|
141
|
foreach my $i ( 1 .. $self->size ) { |
30
|
1522
|
50
|
|
|
|
2050
|
$fh->read( my $data, $OffsetSize ) || die $!; |
31
|
1522
|
|
|
|
|
6012
|
my $offset = unpack( 'N', $data ); |
32
|
1522
|
50
|
|
|
|
2026
|
$fh->read( $data, $SHA1Size ) || die $!; |
33
|
1522
|
|
|
|
|
6051
|
my $sha1 = unpack( 'H*', $data ); |
34
|
1522
|
|
|
|
|
1218
|
push @sha1s, $sha1; |
35
|
1522
|
|
|
|
|
1356
|
$pos += $EntrySize; |
36
|
|
|
|
|
|
|
} |
37
|
4
|
|
|
|
|
469
|
return @sha1s; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_object_offset { |
41
|
2295
|
|
|
2295
|
0
|
2904
|
my ( $self, $want_sha1 ) = @_; |
42
|
2295
|
|
|
|
|
55269
|
my @offsets = $self->offsets; |
43
|
2295
|
|
|
|
|
65822
|
my $fh = $self->fh; |
44
|
|
|
|
|
|
|
|
45
|
2295
|
|
|
|
|
7219
|
my $slot = unpack( 'C', pack( 'H*', $want_sha1 ) ); |
46
|
2295
|
50
|
|
|
|
4349
|
return unless defined $slot; |
47
|
|
|
|
|
|
|
|
48
|
2295
|
|
|
|
|
4000
|
my ( $first, $last ) = @offsets[ $slot, $slot + 1 ]; |
49
|
|
|
|
|
|
|
|
50
|
2295
|
|
|
|
|
3972
|
while ( $first < $last ) { |
51
|
4261
|
|
|
|
|
6102
|
my $mid = int( ( $first + $last ) / 2 ); |
52
|
4261
|
50
|
|
|
|
10073
|
$fh->seek( $SHA1Start + $mid * $EntrySize, 0 ) || die $!; |
53
|
4261
|
50
|
|
|
|
27489
|
$fh->read( my $data, $SHA1Size ) || die $!; |
54
|
4261
|
|
|
|
|
36321
|
my $midsha1 = unpack( 'H*', $data ); |
55
|
4261
|
100
|
|
|
|
9004
|
if ( $midsha1 lt $want_sha1 ) { |
|
|
100
|
|
|
|
|
|
56
|
757
|
|
|
|
|
1625
|
$first = $mid + 1; |
57
|
|
|
|
|
|
|
} elsif ( $midsha1 gt $want_sha1 ) { |
58
|
1209
|
|
|
|
|
2387
|
$last = $mid; |
59
|
|
|
|
|
|
|
} else { |
60
|
2295
|
|
|
|
|
2444
|
my $pos = $OffsetStart + $mid * $EntrySize; |
61
|
2295
|
50
|
|
|
|
4197
|
$fh->seek( $pos, 0 ) || die $!; |
62
|
2295
|
50
|
|
|
|
11740
|
$fh->read( my $data, $OffsetSize ) || die $!; |
63
|
2295
|
|
|
|
|
14203
|
my $offset = unpack( 'N', $data ); |
64
|
2295
|
|
|
|
|
14312
|
return $offset; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
72
|
|
|
|
|
|
|
|