]> Sergey Matveev's repositories - public-inbox.git/commitdiff
xt/git_async_cmp: do not slurp large OID list into memory
authorEric Wong <e@yhbt.net>
Sat, 11 Jan 2020 22:35:01 +0000 (22:35 +0000)
committerEric Wong <e@yhbt.net>
Mon, 13 Jan 2020 04:36:45 +0000 (04:36 +0000)
I somehow thought "foreach (<$cat>)" could work like
"while (<$cat>)" when it came to iterating over file
handles...

xt/git_async_cmp.t

index f8ffe3d9e10a34ae06dfa0f76e8a9136962e0edc..18fce3dbe83df274e6bc4e7bc11e8a226d8d59ff 100644 (file)
@@ -27,7 +27,7 @@ my $async = timeit($nr, sub {
        my $cat = $git->popen(@cat);
        $git->cat_async_begin;
 
-       foreach (<$cat>) {
+       while (<$cat>) {
                my ($oid, undef, undef) = split(/ /);
                $git->cat_async($oid, $cb);
        }
@@ -39,7 +39,7 @@ my $async = timeit($nr, sub {
 my $sync = timeit($nr, sub {
        my $dig = Digest::SHA->new(1);
        my $cat = $git->popen(@cat);
-       foreach (<$cat>) {
+       while (<$cat>) {
                my ($oid, undef, undef) = split(/ /);
                my $bref = $git->cat_file($oid);
                $dig->add($$bref);