diff options
author | Eric Wong <e@80x24.org> | 2023-10-17 23:37:52 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-18 20:50:24 +0000 |
commit | 19b791f4894efcb6e545a6b51c8147298363358f (patch) | |
tree | 16a806fcb0c8fdaef242a2d268a8b1416809b46f /lib/PublicInbox/Git.pm | |
parent | 35b0f7aa00a24f5d89b1b941ec644327ba074c99 (diff) | |
download | public-inbox-19b791f4894efcb6e545a6b51c8147298363358f.tar.gz |
`readline' ops may not detect errors on partial reads. This saves us some code to reduce cognitive overhead for readers. We'll also support reusing a destination buffers so it can work more nicely with existing code.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r-- | lib/PublicInbox/Git.pm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 35bd10ef..a460d155 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -550,11 +550,12 @@ sub modified ($;$) { # read_all/try_cat can probably be moved somewhere else... -sub read_all ($;$) { - my ($fh, $len) = @_; - my $r = read($fh, my $buf, $len //= -s $fh); +sub read_all ($;$$) { + my ($fh, $len, $bref) = @_; + $bref //= \(my $buf); + my $r = read($fh, $$bref, $len //= -s $fh); croak("$fh read ($r != $len)") if $len != $r; - $buf; + $$bref; } sub try_cat { |