line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::PurePerl::PackIndex::Version1; |
2
|
4
|
|
|
4
|
|
15
|
use Moose; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
25
|
|
3
|
4
|
|
|
4
|
|
18284
|
use MooseX::StrictConstructor; |
|
4
|
|
|
|
|
40
|
|
|
4
|
|
|
|
|
34
|
|
4
|
4
|
|
|
4
|
|
8163
|
use namespace::autoclean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
36
|
|
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
|
13
|
return 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub all_sha1s { |
23
|
4
|
|
|
4
|
0
|
8
|
my ( $self, $want_sha1 ) = @_; |
24
|
4
|
|
|
|
|
106
|
my $fh = $self->fh; |
25
|
4
|
|
|
|
|
5
|
my @sha1s; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
7
|
my $pos = $OffsetStart; |
28
|
4
|
50
|
|
|
|
15
|
$fh->seek( $pos, 0 ) || die $!; |
29
|
4
|
|
|
|
|
130
|
foreach my $i ( 1 .. $self->size ) { |
30
|
1522
|
50
|
|
|
|
1759
|
$fh->read( my $data, $OffsetSize ) || die $!; |
31
|
1522
|
|
|
|
|
4779
|
my $offset = unpack( 'N', $data ); |
32
|
1522
|
50
|
|
|
|
1714
|
$fh->read( $data, $SHA1Size ) || die $!; |
33
|
1522
|
|
|
|
|
4830
|
my $sha1 = unpack( 'H*', $data ); |
34
|
1522
|
|
|
|
|
1035
|
push @sha1s, $sha1; |
35
|
1522
|
|
|
|
|
1176
|
$pos += $EntrySize; |
36
|
|
|
|
|
|
|
} |
37
|
4
|
|
|
|
|
344
|
return @sha1s; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_object_offset { |
41
|
2261
|
|
|
2261
|
0
|
2160
|
my ( $self, $want_sha1 ) = @_; |
42
|
2261
|
|
|
|
|
51400
|
my @offsets = $self->offsets; |
43
|
2261
|
|
|
|
|
59805
|
my $fh = $self->fh; |
44
|
|
|
|
|
|
|
|
45
|
2261
|
|
|
|
|
6122
|
my $slot = unpack( 'C', pack( 'H*', $want_sha1 ) ); |
46
|
2261
|
50
|
|
|
|
3393
|
return unless defined $slot; |
47
|
|
|
|
|
|
|
|
48
|
2261
|
|
|
|
|
3137
|
my ( $first, $last ) = @offsets[ $slot, $slot + 1 ]; |
49
|
|
|
|
|
|
|
|
50
|
2261
|
|
|
|
|
3286
|
while ( $first < $last ) { |
51
|
4195
|
|
|
|
|
5480
|
my $mid = int( ( $first + $last ) / 2 ); |
52
|
4195
|
50
|
|
|
|
8533
|
$fh->seek( $SHA1Start + $mid * $EntrySize, 0 ) || die $!; |
53
|
4195
|
50
|
|
|
|
23675
|
$fh->read( my $data, $SHA1Size ) || die $!; |
54
|
4195
|
|
|
|
|
30342
|
my $midsha1 = unpack( 'H*', $data ); |
55
|
4195
|
100
|
|
|
|
7873
|
if ( $midsha1 lt $want_sha1 ) { |
|
|
100
|
|
|
|
|
|
56
|
742
|
|
|
|
|
1266
|
$first = $mid + 1; |
57
|
|
|
|
|
|
|
} elsif ( $midsha1 gt $want_sha1 ) { |
58
|
1192
|
|
|
|
|
2137
|
$last = $mid; |
59
|
|
|
|
|
|
|
} else { |
60
|
2261
|
|
|
|
|
2005
|
my $pos = $OffsetStart + $mid * $EntrySize; |
61
|
2261
|
50
|
|
|
|
3654
|
$fh->seek( $pos, 0 ) || die $!; |
62
|
2261
|
50
|
|
|
|
10480
|
$fh->read( my $data, $OffsetSize ) || die $!; |
63
|
2261
|
|
|
|
|
12501
|
my $offset = unpack( 'N', $data ); |
64
|
2261
|
|
|
|
|
12899
|
return $offset; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
72
|
|
|
|
|
|
|
|