This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_hot.c: skip unnecessary test
authorDavid Mitchell <davem@iabyn.com>
Sat, 11 Jul 2015 15:43:25 +0000 (16:43 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:36 +0000 (08:59 +0000)
This condition:

    !CvROOT(cv) && !CvXSUB(cv)

can be simplified because those two cv fields are actually
the same slot in a union.

pp_hot.c

index f9a40fd..6d7b5e2 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3431,7 +3431,10 @@ PP(pp_entersub)
 
     ENTER;
 
-    while (UNLIKELY(!CvROOT(cv) && !CvXSUB(cv))) {
+    /* these two fields are in a union. If they ever become separate,
+     * we have to test for both of them being null below */
+    assert((void*)&CvROOT(cv) == (void*)&CvXSUB(cv));
+    while (UNLIKELY(!CvROOT(cv))) {
        GV* autogv;
        SV* sub_name;