Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
git-svn: use sys* IO functions for reading rev_db
author
Eric Wong
<normalperson@yhbt.net>
Thu, 1 Feb 2007 01:57:36 +0000
(17:57 -0800)
committer
Eric Wong
<normalperson@yhbt.net>
Fri, 23 Feb 2007 08:57:11 +0000
(
00:57
-0800)
Using buffered IO for reading 40-41 bytes at a time isn't very
efficient. Buffering writes for a short duration is alright
since we close() right away and buffers will be flushed.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
9c93fee
)
diff --git
a/git-svn.perl
b/git-svn.perl
index b1d91fa471b11ef6ab2f9c005bb1efac6ea53119..1e3a3c08f11372857c5152d7c20b50df8784a673 100755
(executable)
--- a/
git-svn.perl
+++ b/
git-svn.perl
@@
-891,23
+891,20
@@
sub last_rev_commit {
my $rl;
open my $fh, '<', $self->{db_path} or
croak "$self->{db_path} not readable: $!\n";
my $rl;
open my $fh, '<', $self->{db_path} or
croak "$self->{db_path} not readable: $!\n";
- seek $fh, $offset, 2;
- $rl = readline $fh;
- defined $rl or return (undef, undef);
+ sysseek($fh, $offset, 2); # don't care for errors
+ sysread($fh, $rl, 41) == 41 or return (undef, undef);
chomp $rl;
chomp $rl;
- while (('0' x40) eq $rl &&
tell $fh
!= 0) {
+ while (('0' x40) eq $rl &&
sysseek($fh, 0, 1)
!= 0) {
$offset -= 41;
$offset -= 41;
- seek $fh, $offset, 2;
- $rl = readline $fh;
- defined $rl or return (undef, undef);
+ sysseek($fh, $offset, 2); # don't care for errors
+ sysread($fh, $rl, 41) == 41 or return (undef, undef);
chomp $rl;
}
if ($c) {
die "$self->{db_path} and ", $self->refname,
" inconsistent!:\n$c != $rl\n";
}
chomp $rl;
}
if ($c) {
die "$self->{db_path} and ", $self->refname,
" inconsistent!:\n$c != $rl\n";
}
- my $rev = tell $fh;
- croak $! if ($rev < 0);
+ my $rev = sysseek($fh, 0, 1) or croak $!;
$rev = ($rev - 41) / 41;
close $fh or croak $!;
($self->{last_rev}, $self->{last_commit}) = ($rev, $c);
$rev = ($rev - 41) / 41;
close $fh or croak $!;
($self->{last_rev}, $self->{last_commit}) = ($rev, $c);
@@
-1419,12
+1416,9
@@
sub rev_db_get {
my $ret;
my $offset = $rev * 41;
open my $fh, '<', $self->{db_path} or croak $!;
my $ret;
my $offset = $rev * 41;
open my $fh, '<', $self->{db_path} or croak $!;
- if (seek $fh, $offset, 0) {
- $ret = readline $fh;
- if (defined $ret) {
- chomp $ret;
- $ret = undef if ($ret =~ /^0{40}$/);
- }
+ if (sysseek($fh, $offset, 0) == $offset) {
+ my $read = sysread($fh, $ret, 40);
+ $ret = undef if ($read != 40 || $ret eq ('0'x40));
}
close $fh or croak $!;
$ret;
}
close $fh or croak $!;
$ret;