summaryrefslogtreecommitdiff
path: root/cpan/ExtUtils-Constant
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-23 07:36:53 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-23 07:40:53 +0100
commita0074a595ba9467095da80f22054deac26706f64 (patch)
treecaf67177d282cac6179ff16866bc9484ea0713a0 /cpan/ExtUtils-Constant
parent28c5c15c9196adf231d52b99e78f3de3d7b63e2b (diff)
downloadperl-a0074a595ba9467095da80f22054deac26706f64.tar.gz
For PROXYSUBS, also avoid calling get_missing_hash() in the XS constant code.
(Follow on from 4639bd9c727433ad) For modules such as File::Glob and I18N::Langinfo, which always define all constants on all platforms, this saves about 700 bytes of object code.
Diffstat (limited to 'cpan/ExtUtils-Constant')
-rw-r--r--cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm20
1 files changed, 16 insertions, 4 deletions
diff --git a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm
index d9eca8bfa1..15c679f593 100644
--- a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm
+++ b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm
@@ -581,8 +581,14 @@ EOA
print $xs_fh <<"EOC";
PPCODE:
#ifndef SYMBIAN
- HV *${c_subname}_missing = get_missing_hash(aTHX);
- if (hv_exists_ent(${c_subname}_missing, sv, 0)) {
+ /* It's not obvious how to calculate this at C pre-processor time.
+ However, any compiler optimiser worth its salt should be able to
+ remove the dead code, and hopefully the now-obviously-unused static
+ function too. */
+ HV *${c_subname}_missing = (C_ARRAY_LENGTH(values_for_notfound) > 1)
+ ? get_missing_hash(aTHX) : NULL;
+ if ((C_ARRAY_LENGTH(values_for_notfound) > 1)
+ ? hv_exists_ent(${c_subname}_missing, sv, 0) : 0) {
sv = newSVpvf("Your vendor has not defined $package_sprintf_safe macro %" SVf
", used at %" COP_FILE_F " line %d\\n", sv,
COP_FILE(cop), CopLINE(cop));
@@ -613,8 +619,14 @@ $xs_subname(sv)
SV * sv;
PPCODE:
#ifndef SYMBIAN
- HV *${c_subname}_missing = get_missing_hash(aTHX);
- if (hv_exists_ent(${c_subname}_missing, sv, 0)) {
+ /* It's not obvious how to calculate this at C pre-processor time.
+ However, any compiler optimiser worth its salt should be able to
+ remove the dead code, and hopefully the now-obviously-unused static
+ function too. */
+ HV *${c_subname}_missing = (C_ARRAY_LENGTH(values_for_notfound) > 1)
+ ? get_missing_hash(aTHX) : NULL;
+ if ((C_ARRAY_LENGTH(values_for_notfound) > 1)
+ ? hv_exists_ent(${c_subname}_missing, sv, 0) : NULL) {
sv = newSVpvf("Your vendor has not defined $package_sprintf_safe macro %" SVf
", used", sv);
} else