summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-10-25 12:05:16 +0200
committerYves Orton <demerphq@gmail.com>2022-10-26 11:11:08 +0200
commit7b038bdfcf431a73f1f1fa9c4494322ed4fc8ae2 (patch)
tree1a6a646059a9e412a914eecf2846c0bd3afa5315
parenta73e2f42e4d90aabd3c1f9b45b5b18fab652e36e (diff)
downloadperl-7b038bdfcf431a73f1f1fa9c4494322ed4fc8ae2.tar.gz
feature.h - simplify expression CURRENT_HINTS expression
PL_hints expands to PL_compiling.cop_hints. So there is no point in doing PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints as it resolves to doing: PL_curcop->cop_hints but with a comparison, which likely kills any speed advantage the direct access might provide. The old define is left around to validate that the two are the same if needed.
-rw-r--r--feature.h7
-rwxr-xr-xregen/feature.pl7
2 files changed, 12 insertions, 2 deletions
diff --git a/feature.h b/feature.h
index f10e25cb5a..08061e12c8 100644
--- a/feature.h
+++ b/feature.h
@@ -43,8 +43,13 @@
#define FEATURE_BUNDLE_537 7
#define FEATURE_BUNDLE_CUSTOM (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
-#define CURRENT_HINTS \
+/* this is preserved for testing and asserts */
+#define OLD_CURRENT_HINTS \
(PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
+/* this is the same thing, but simpler (no if) as PL_hints expands
+ to PL_compiling.cop_hints */
+#define CURRENT_HINTS \
+ PL_curcop->cop_hints
#define CURRENT_FEATURE_BUNDLE \
((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT)
diff --git a/regen/feature.pl b/regen/feature.pl
index e271454d78..11cfbcfd0c 100755
--- a/regen/feature.pl
+++ b/regen/feature.pl
@@ -305,8 +305,13 @@ for (@HintedBundles) {
print $h <<'EOH';
#define FEATURE_BUNDLE_CUSTOM (HINT_FEATURE_MASK >> HINT_FEATURE_SHIFT)
-#define CURRENT_HINTS \
+/* this is preserved for testing and asserts */
+#define OLD_CURRENT_HINTS \
(PL_curcop == &PL_compiling ? PL_hints : PL_curcop->cop_hints)
+/* this is the same thing, but simpler (no if) as PL_hints expands
+ to PL_compiling.cop_hints */
+#define CURRENT_HINTS \
+ PL_curcop->cop_hints
#define CURRENT_FEATURE_BUNDLE \
((CURRENT_HINTS & HINT_FEATURE_MASK) >> HINT_FEATURE_SHIFT)