This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
This commit speeds up class method calls when class name is constant.
[perl5.git] / pp_hot.c
index 4908525..8ec576a 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3006,15 +3006,21 @@ S_method_common(pTHX_ SV* meth, U32* hashp)
     SV* ob;
     GV* gv;
     HV* stash;
-    SV *packsv = NULL;
-    SV * const sv = PL_stack_base + TOPMARK == PL_stack_sp
+    SV *packsv = NULL, *const_class, *sv;
+
+    PERL_ARGS_ASSERT_METHOD_COMMON;
+
+    if ((const_class = cMETHOPx_class(PL_op))) {
+       stash = gv_stashsv(const_class, GV_CACHE_ONLY);
+       if (stash) goto fetch;
+    }
+
+    sv = PL_stack_base + TOPMARK == PL_stack_sp
        ? (Perl_croak(aTHX_ "Can't call method \"%"SVf"\" without a "
                            "package or object reference", SVfARG(meth)),
           (SV *)NULL)
        : *(PL_stack_base + TOPMARK + 1);
 
-    PERL_ARGS_ASSERT_METHOD_COMMON;
-
     if (UNLIKELY(!sv))
        undefined:
        Perl_croak(aTHX_ "Can't call method \"%"SVf"\" on an undefined value",