develooper Front page | perl.perl5.porters | Postings from February 2003

[PATCH] use PL_*gv instead of calling gv_fetchpv() again

From:
Chip Salzenberg
Date:
February 23, 2003 11:15
Subject:
[PATCH] use PL_*gv instead of calling gv_fetchpv() again
Message ID:
20030223191436.GH3090@perlsupport.com
What with PL_argvgv, there's no need to call gv_fetchpv("ARGV")
after startup.  This this patch.

In looking for other occurrences of similar unnecessary fetching, I
found that there's no PL_stdoutgv.  I'm not sure whether that's a bug.
Granted you usually want PL_defoutgv instead, but sometimes you really
do want stdout.

PS: The win32 part I can't test.  Opinions before I commit?


==== //depot/perl/op.c#541 - /u/src/perl/current/op.c ====
@@ -4693,6 +4693,5 @@
 	if (cLISTOPo->op_first->op_type == OP_STUB) {
 	    op_free(o);
-	    o = newUNOP(type, OPf_SPECIAL,
-		newGVOP(OP_GV, 0, gv_fetchpv("main::ARGV", TRUE, SVt_PVAV)));
+	    o = newUNOP(type, OPf_SPECIAL, newGVOP(OP_GV, 0, PL_argvgv));
 	}
 	return ck_fun(o);
@@ -5565,6 +5564,5 @@
 	op_free(o);
 	argop = newUNOP(OP_RV2AV, 0,
-	    scalar(newGVOP(OP_GV, 0, !CvUNIQUE(PL_compcv) ?
-			   PL_defgv : gv_fetchpv("ARGV", TRUE, SVt_PVAV))));
+	    scalar(newGVOP(OP_GV, 0, CvUNIQUE(PL_compcv) ? PL_argvgv : PL_defgv)));
 	return newUNOP(type, 0, scalar(argop));
     }
==== //depot/perl/win32/perlhost.h#55 - /u/src/perl/current/win32/perlhost.h ====
@@ -1775,7 +1775,7 @@
     /* close the std handles to avoid fd leaks */
     {
-	do_close(gv_fetchpv("STDIN", TRUE, SVt_PVIO), FALSE);
-	do_close(gv_fetchpv("STDOUT", TRUE, SVt_PVIO), FALSE);
-	do_close(gv_fetchpv("STDERR", TRUE, SVt_PVIO), FALSE);
+	do_close(PL_stdingv, FALSE);
+	do_close(gv_fetchpv("STDOUT", TRUE, SVt_PVIO), FALSE); /* PL_stdoutgv - ISAGN */
+	do_close(PL_stderrgv, FALSE);
     }
 

-- 
Chip Salzenberg         - a.k.a.  -        <chip@pobox.com>
         "It furthers one to have somewhere to go."



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About