Skip to content

Commit bcaaf42

Browse files
committed
gv_magicalize: Quickly rule non-magical input out
This uses the data structure introduced in the previous commit to quickly test the input first character. If it isn't a potential magical one, no need to look further.
1 parent 3b2f9a1 commit bcaaf42

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

gv.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,10 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
20902090
return false;
20912091
}
20922092

2093+
if (! generic_isCC_(*name, CC_MAGICAL_)) {
2094+
goto try_core;
2095+
}
2096+
20932097
if (stash != PL_defstash) { /* not the main stash */
20942098
/* We only have to check for a few names here: a, b, EXPORT, ISA
20952099
and VERSION. All the others apply only to the main stash or to
@@ -2136,22 +2140,6 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
21362140
}
21372141
}
21382142
else if (len > 1) {
2139-
#ifndef EBCDIC
2140-
if (*name > 'V' ) {
2141-
NOOP;
2142-
/* Nothing else to do.
2143-
The compiler will probably turn the switch statement into a
2144-
branch table. Make sure we avoid even that small overhead for
2145-
the common case of lower case variable names. (On EBCDIC
2146-
platforms, we can't just do:
2147-
if (NATIVE_TO_ASCII(*name) > NATIVE_TO_ASCII('V') ) {
2148-
because cases like '\027' in the switch statement below are
2149-
C1 (non-ASCII) controls on those platforms, so the remapping
2150-
would make them larger than 'V')
2151-
*/
2152-
} else
2153-
#endif
2154-
{
21552143
switch (*name) {
21562144
case 'A':
21572145
if (memEQs(name, len, "ARGV")) {
@@ -2313,7 +2301,6 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
23132301
goto storeparen;
23142302
}
23152303
}
2316-
}
23172304
} else {
23182305
/* Names of length 1. (Or 0. But name is NUL terminated, so that will
23192306
be case '\0' in this switch statement (ie a default case) */

0 commit comments

Comments
 (0)