regcomp.c:current_re_engine: Avoid %^H lookup when possible
authorFather Chrysostomos <sprout@cpan.org>
Sat, 7 Sep 2013 20:34:24 +0000 (13:34 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 8 Sep 2013 01:34:37 +0000 (18:34 -0700)
Modification of %^H sets a flag in PL_hints, so we can check
that flag to avoid the slight overhead of has lookup if %^H
has not been used.

regcomp.c

index e0787e1..931f8fb 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -4881,7 +4881,7 @@ Perl_current_re_engine(pTHX)
        HV * const table = GvHV(PL_hintgv);
        SV **ptr;
 
-       if (!table)
+       if (!table || !(PL_hints & HINT_LOCALIZE_HH))
            return &PL_core_reg_engine;
        ptr = hv_fetchs(table, "regcomp", FALSE);
        if ( !(ptr && SvIOK(*ptr) && SvIV(*ptr)))