Reserializing the message to a string to check size wastes
considerable time and should be able to get by with slightly
less accuracy.
}
sub cat_file {
- my ($self, $object) = @_;
+ my ($self, $object, $sizeref) = @_;
$object .= "\n";
my $len = bytes::length($object);
die "Unexpected result from git cat-file: $head\n";
my $size = $1;
+ $$sizeref = $size if $sizeref;
my $bytes_left = $size;
my $offset = 0;
my $rv = '';
}
found:
my $o = 'HEAD:' . mid2path($mid);
- my $s = eval { Email::Simple->new($ng->gcf->cat_file($o)) };
+ my $bytes;
+ my $s = eval { Email::Simple->new($ng->gcf->cat_file($o, \$bytes)) };
return $err unless $s;
if ($set_headers) {
$s->header_set('Newsgroups', $ng->{name});
# must be last
if ($set_headers == 2) {
- $s->header_set('Bytes', bytes::length($s->as_string));
+ $s->header_set('Bytes', $bytes);
$s->body_set('');
}
}