]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
runtests: stop copying a few arrays where not needed
authorDan Fandrich <dan@coneharvesters.com>
Wed, 22 Mar 2023 19:13:49 +0000 (12:13 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Thu, 30 Mar 2023 16:12:52 +0000 (09:12 -0700)
Unlike some other languages that just copy a pointer, perl copies the
entire array contents which takes time for a large array.

Ref: #10818

tests/runtests.pl

index 33deae430c483e8a0d895c1292dfb72d5871373b..42e84a103ea873f096fdbfe4258d5a2a7e5e403b 100755 (executable)
@@ -4554,22 +4554,20 @@ sub singletest {
         # Verify the sent request
         my @out = loadarray($SERVERIN);
 
-        my @protstrip=@protocol;
-
         # check if there's any attributes on the verify/protocol section
         my %hash = getpartattr("verify", "protocol");
 
         if($hash{'nonewline'}) {
             # Yes, we must cut off the final newline from the final line
             # of the protocol data
-            chomp($protstrip[$#protstrip]);
+            chomp($protocol[$#protocol]);
         }
 
         for(@strip) {
             # strip off all lines that match the patterns from both arrays
             chomp $_;
             @out = striparray( $_, \@out);
-            @protstrip= striparray( $_, \@protstrip);
+            @protocol= striparray( $_, \@protocol);
         }
 
         my $strip;
@@ -4582,17 +4580,17 @@ sub singletest {
         }
 
         if($hash{'crlf'}) {
-            map subNewlines(1, \$_), @protstrip;
+            map subNewlines(1, \$_), @protocol;
         }
 
-        if((!$out[0] || ($out[0] eq "")) && $protstrip[0]) {
+        if((!$out[0] || ($out[0] eq "")) && $protocol[0]) {
             logmsg "\n $testnum: protocol FAILED!\n".
                 " There was no content at all in the file $SERVERIN.\n".
                 " Server glitch? Total curl failure? Returned: $cmdres\n";
             return $errorreturncode;
         }
 
-        $res = compare($testnum, $testname, "protocol", \@out, \@protstrip);
+        $res = compare($testnum, $testname, "protocol", \@out, \@protocol);
         if($res) {
             return $errorreturncode;
         }
@@ -4642,23 +4640,21 @@ sub singletest {
     my @proxyprot = getpart("verify", "proxy");
     if(@proxyprot) {
         # Verify the sent proxy request
-        my @out = loadarray($PROXYIN);
-        my @protstrip=@proxyprot;
-
         # check if there's any attributes on the verify/protocol section
         my %hash = getpartattr("verify", "proxy");
 
         if($hash{'nonewline'}) {
             # Yes, we must cut off the final newline from the final line
             # of the protocol data
-            chomp($protstrip[$#protstrip]);
+            chomp($proxyprot[$#proxyprot]);
         }
 
+        my @out = loadarray($PROXYIN);
         for(@strip) {
             # strip off all lines that match the patterns from both arrays
             chomp $_;
             @out = striparray( $_, \@out);
-            @protstrip= striparray( $_, \@protstrip);
+            @proxyprot= striparray( $_, \@proxyprot);
         }
 
         my $strip;
@@ -4671,10 +4667,10 @@ sub singletest {
 
         if($hash{'crlf'} ||
            ($has_hyper && ($keywords{"HTTP"} || $keywords{"HTTPS"}))) {
-            map subNewlines(0, \$_), @protstrip;
+            map subNewlines(0, \$_), @proxyprot;
         }
 
-        $res = compare($testnum, $testname, "proxy", \@out, \@protstrip);
+        $res = compare($testnum, $testname, "proxy", \@out, \@proxyprot);
         if($res) {
             return $errorreturncode;
         }