diff options
author | Yves Orton <demerphq@gmail.com> | 2022-10-25 12:05:16 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2022-10-26 11:11:08 +0200 |
commit | 7b038bdfcf431a73f1f1fa9c4494322ed4fc8ae2 (patch) | |
tree | 1a6a646059a9e412a914eecf2846c0bd3afa5315 | |
parent | a73e2f42e4d90aabd3c1f9b45b5b18fab652e36e (diff) | |
download | perl-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.h | 7 | ||||
-rwxr-xr-x | regen/feature.pl | 7 |
2 files changed, 12 insertions, 2 deletions
@@ -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) |