From 7bca96023bb26438a5c9d0a7eec3986f5d66f5bf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 17 May 2020 19:48:14 +0000 Subject: favor readline() and print() as functions In our inbox-writing code paths, ->getline as an OO method may be confused with the various definitions of `getline' used by the PSGI interface. It's also easier to do: "perldoc -f readline" than to figure out which class "->getline" belongs to (IO::Handle) and lookup documentation for that. ->print is less confusing than the "readline" vs "getline" mismatch, but we can still make it clear we're using a real file handle and not a mock interface. Finally, functions are a bit faster than their OO counterparts. --- script/public-inbox-convert | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'script') diff --git a/script/public-inbox-convert b/script/public-inbox-convert index 4c220b36..7fb15adf 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -111,12 +111,12 @@ while (<$rd>) { $state = 'commit'; } elsif (/^data ([0-9]+)/) { my $len = $1; - $w->print($_) or $im->wfail; + print $w $_ or $im->wfail; while ($len) { my $n = read($rd, my $tmp, $len) or die "read: $!"; warn "$n != $len\n" if $n != $len; $len -= $n; - $w->print($tmp) or $im->wfail; + print $w $tmp or $im->wfail; } next; } elsif ($state eq 'commit') { @@ -124,9 +124,9 @@ while (<$rd>) { my ($mark, $path) = ($1, $2); $D{$path} = $mark; if ($last && $last ne 'm') { - $w->print("D $last\n") or $im->wfail; + print $w "D $last\n" or $im->wfail; } - $w->print("M 100644 :$mark m\n") or $im->wfail; + print $w "M 100644 :$mark m\n" or $im->wfail; $last = 'm'; next; } @@ -134,15 +134,15 @@ while (<$rd>) { my $mark = delete $D{$1}; defined $mark or die "undeleted path: $1\n"; if ($last && $last ne 'd') { - $w->print("D $last\n") or $im->wfail; + print $w "D $last\n" or $im->wfail; } - $w->print("M 100644 :$mark d\n") or $im->wfail; + print $w "M 100644 :$mark d\n" or $im->wfail; $last = 'd'; next; } } last if $_ eq "done\n"; - $w->print($_) or $im->wfail; + print $w $_ or $im->wfail; } $w = $r = undef; close $rd or die "close fast-export: $!\n"; -- cgit v1.2.3-24-ge0c7