This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In Perl_pad_new(), avoid calling av_fetch() for something we already know.
authorNicholas Clark <nick@ccl4.org>
Tue, 16 Nov 2010 10:51:26 +0000 (10:51 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 16 Nov 2010 10:51:26 +0000 (10:51 +0000)
We've just stored padname and pad as the first two elements in padlist - so
calling av_fetch() is makework.

The code was the way it was because dd2155a49b710f23 moved the two halves from
disjoint locations into the same function adjacent to each other, but didn't
spot this subsequent optimisation.

pad.c

diff --git a/pad.c b/pad.c
index 1fcd375..07630c2 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -214,9 +214,9 @@ Perl_pad_new(pTHX_ int flags)
 
     /* ... then update state variables */
 
-    PL_comppad_name    = MUTABLE_AV((*av_fetch(padlist, 0, FALSE)));
-    PL_comppad         = MUTABLE_AV((*av_fetch(padlist, 1, FALSE)));
-    PL_curpad          = AvARRAY(PL_comppad);
+    PL_comppad_name    = padname;
+    PL_comppad         = pad;
+    PL_curpad          = AvARRAY(pad);
 
     if (! (flags & padnew_CLONE)) {
        PL_comppad_name_fill = 0;