summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2019-10-25 05:26:53 +1100
committerTony Cook <tony@develop-help.com>2019-10-30 20:09:37 +0100
commit9f601cf3bbfa6be3e2ab3468e77a7b79c80ff5cf (patch)
treecfb97c690e5e69e19f3e73fe532606008a1cd5ab /mg.c
parent698f6cc7d55bb6b96940a610be050d2c6331ae04 (diff)
downloadperl-9f601cf3bbfa6be3e2ab3468e77a7b79c80ff5cf.tar.gz
Faster feature checks
Perform only a bit check instead of a much more expensive hash lookup to test features. For now I've just added a U32 to the cop structure to store the bits, if we need more we could either add more bits directly, or make it a pointer. We don't have the immediate need for a pointer that warning do since we don't dynamically add new features during compilation/runtime. The changes to %^H are retained so that caller() can be used from perl code to check the features enabled at a given caller's scope.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/mg.c b/mg.c
index f235f0ee5a..7d2314fd64 100644
--- a/mg.c
+++ b/mg.c
@@ -1032,7 +1032,12 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
break;
case '\006': /* ^F */
- sv_setiv(sv, (IV)PL_maxsysfd);
+ if (nextchar == '\0') {
+ sv_setiv(sv, (IV)PL_maxsysfd);
+ }
+ else if (strEQ(remaining, "EATURE_BITS")) {
+ sv_setuv(sv, PL_compiling.cop_features);
+ }
break;
case '\007': /* ^GLOBAL_PHASE */
if (strEQ(remaining, "LOBAL_PHASE")) {
@@ -2840,7 +2845,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
Perl_croak(aTHX_ "${^ENCODING} is no longer supported");
break;
case '\006': /* ^F */
- PL_maxsysfd = SvIV(sv);
+ if (mg->mg_ptr[1] == '\0') {
+ PL_maxsysfd = SvIV(sv);
+ }
+ else if (strEQ(mg->mg_ptr + 1, "EATURE_BITS")) {
+ PL_compiling.cop_features = SvUV(sv);
+ }
break;
case '\010': /* ^H */
{