diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-10-20 19:17:51 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-10-21 08:42:22 +0200 |
commit | 76cc365d064e9bf5a0e771bb8ae2bf380b8b0d25 (patch) | |
tree | 219d04dd1b231d08fd8a358aa69212295d62349b /ext/Hash-Util | |
parent | 2caa6900bf5b16874efdd1f85c3db1c9f6bcb5fd (diff) | |
download | perl-76cc365d064e9bf5a0e771bb8ae2bf380b8b0d25.tar.gz |
Merge the XS code for Hash::Util::{hidden,legal}_ref_keys.
Express Hash::Util::all_keys more tersely.
Diffstat (limited to 'ext/Hash-Util')
-rw-r--r-- | ext/Hash-Util/Util.xs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/ext/Hash-Util/Util.xs b/ext/Hash-Util/Util.xs index e65f42874e..d835edeb85 100644 --- a/ext/Hash-Util/Util.xs +++ b/ext/Hash-Util/Util.xs @@ -2,10 +2,8 @@ #include "perl.h" #include "XSUB.h" - MODULE = Hash::Util PACKAGE = Hash::Util - void all_keys(hash,keys,placeholder) HV *hash @@ -22,45 +20,30 @@ all_keys(hash,keys,placeholder) (void)hv_iterinit(hash); while((he = hv_iternext_flags(hash, HV_ITERNEXT_WANTPLACEHOLDERS))!= NULL) { key=hv_iterkeysv(he); - if (HeVAL(he) == &PL_sv_placeholder) { - SvREFCNT_inc(key); - av_push(placeholder, key); - } else { - SvREFCNT_inc(key); - av_push(keys, key); - } + av_push(HeVAL(he) == &PL_sv_placeholder ? placeholder : keys, + SvREFCNT_inc(key)); } XSRETURN(1); void hidden_ref_keys(hash) HV *hash + ALIAS: + Hash::Util::legal_ref_keys = 1 PREINIT: + dXSI32; SV *key; HE *he; PPCODE: (void)hv_iterinit(hash); while((he = hv_iternext_flags(hash, HV_ITERNEXT_WANTPLACEHOLDERS))!= NULL) { key=hv_iterkeysv(he); - if (HeVAL(he) == &PL_sv_placeholder) { + if (ix || HeVAL(he) == &PL_sv_placeholder) { XPUSHs( key ); } } void -legal_ref_keys(hash) - HV *hash - PREINIT: - SV *key; - HE *he; - PPCODE: - (void)hv_iterinit(hash); - while((he = hv_iternext_flags(hash, HV_ITERNEXT_WANTPLACEHOLDERS))!= NULL) { - key=hv_iterkeysv(he); - XPUSHs( key ); - } - -void hv_store(hash, key, val) HV *hash SV* key |