This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
performance tweaking op.c
authorAndy Lester <andy@petdance.com>
Fri, 6 Jan 2006 01:44:48 +0000 (19:44 -0600)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 6 Jan 2006 14:35:38 +0000 (14:35 +0000)
Message-ID: <20060106074448.GB3401@petdance.com>

p4raw-id: //depot/perl@26674

op.c

diff --git a/op.c b/op.c
index b9b1440..065c684 100644 (file)
--- a/op.c
+++ b/op.c
@@ -209,10 +209,11 @@ PADOFFSET
 Perl_allocmy(pTHX_ char *name)
 {
     PADOFFSET off;
+    const bool is_our = (PL_in_my == KEY_our);
 
     /* complain about "my $<special_var>" etc etc */
     if (*name &&
-       !(PL_in_my == KEY_our ||
+       !(is_our ||
          isALPHA(name[1]) ||
          (USE_UTF8_IN_NAMES && UTF8_IS_START(name[1])) ||
          (name[1] == '_' && (*name == '$' || name[2]))))
@@ -241,22 +242,19 @@ Perl_allocmy(pTHX_ char *name)
     }
 
     /* check for duplicate declaration */
-    pad_check_dup(name,
-               (bool)(PL_in_my == KEY_our),
-               (PL_curstash ? PL_curstash : PL_defstash)
-    );
+    pad_check_dup(name, is_our, (PL_curstash ? PL_curstash : PL_defstash));
 
     if (PL_in_my_stash && *name != '$') {
        yyerror(Perl_form(aTHX_
                    "Can't declare class for non-scalar %s in \"%s\"",
-                    name, PL_in_my == KEY_our ? "our" : "my"));
+                    name, is_our ? "our" : "my"));
     }
 
     /* allocate a spare slot and store the name in that slot */
 
     off = pad_add_name(name,
                    PL_in_my_stash,
-                   (PL_in_my == KEY_our 
+                   (is_our
                        /* $_ is always in main::, even with our */
                        ? (PL_curstash && !strEQ(name,"$_") ? PL_curstash : PL_defstash)
                        : NULL
@@ -507,19 +505,25 @@ Perl_op_refcnt_unlock(pTHX)
 OP *
 Perl_linklist(pTHX_ OP *o)
 {
+    OP *first;
 
     if (o->op_next)
        return o->op_next;
 
     /* establish postfix order */
-    if (cUNOPo->op_first) {
+    first = cUNOPo->op_first;
+    if (first) {
         register OP *kid;
-       o->op_next = LINKLIST(cUNOPo->op_first);
-       for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) {
-           if (kid->op_sibling)
+       o->op_next = LINKLIST(first);
+       kid = first;
+       for (;;) {
+           if (kid->op_sibling) {
                kid->op_next = LINKLIST(kid->op_sibling);
-           else
+               kid = kid->op_sibling;
+           } else {
                kid->op_next = o;
+               break;
+           }
        }
     }
     else