summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Witten <mfwitten@gmail.com>2011-03-14 06:57:43 +0000
committerFather Chrysostomos <sprout@cpan.org>2011-05-18 16:35:16 -0700
commit1b95d04f713d9c56e4957326f9f6b0481216a00c (patch)
tree9f57b4048cfba9c60f2f933d4e9305cc149dfa80
parentb9f41ca854adae9c928d96cb3c1612b18866516e (diff)
downloadperl-1b95d04f713d9c56e4957326f9f6b0481216a00c.tar.gz
Clean: Actually use HvUSEDKEYS() instead of HvKEYS()
This: commit 8aacddc1ea3837f8f1a911d90c644451fc7cfc86 Author: Nick Ing-Simmons <nik@tiuk.ti.com> Date: Tue Dec 18 15:55:22 2001 +0000 Tidied version of Jeffrey Friedl's <jfriedl@yahoo.com> restricted hashes - added delete of READONLY value inhibit & test for same - re-tabbed p4raw-id: //depot/perlio@13760 essentially deprecated HvKEYS() in favor of HvUSEDKEYS(); this is explained in line 144 (now 313) of file `hv.h': /* * HvKEYS gets the number of keys that actually exist(), and is provided * for backwards compatibility with old XS code. The core uses HvUSEDKEYS * (keys, excluding placeholdes) and HvTOTALKEYS (including placeholders) */ This commit simply puts that into practice, and is equivalent to running the following (at least with a35ef416833511da752c4b5b836b7a8915712aab checked out): git grep -l HvKEYS | sed /hv.h/d | xargs sed -i s/HvKEYS/HvUSEDKEYS/ Notice that HvKEYS is currently just an alias for HvUSEDKEYS: $ git show a35ef416833511da752c4b5b836b7a8915712aab:hv.h | sed -n 318p #define HvKEYS(hv) HvUSEDKEYS(hv) According to `make tests': All tests successful.
-rw-r--r--dist/Storable/Storable.xs2
-rw-r--r--dist/threads-shared/shared.xs2
-rw-r--r--doop.c4
-rw-r--r--dump.c8
-rw-r--r--ext/B/B.xs4
-rw-r--r--hv.c8
-rw-r--r--mg.c2
-rw-r--r--mro.c2
-rw-r--r--pp.c2
-rw-r--r--pp_hot.c2
-rw-r--r--t/benchmark/rt26188-speed-up-keys-on-empty-hash.t2
11 files changed, 19 insertions, 19 deletions
diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs
index 317ada795d..e6d403b624 100644
--- a/dist/Storable/Storable.xs
+++ b/dist/Storable/Storable.xs
@@ -2289,7 +2289,7 @@ static int store_hash(pTHX_ stcxt_t *cxt, HV *hv)
#ifdef HAS_RESTRICTED_HASHES
HvTOTALKEYS(hv);
#else
- HvKEYS(hv);
+ HvUSEDKEYS(hv);
#endif
I32 i;
int ret = 0;
diff --git a/dist/threads-shared/shared.xs b/dist/threads-shared/shared.xs
index 7f1cd06715..13e4a564b4 100644
--- a/dist/threads-shared/shared.xs
+++ b/dist/threads-shared/shared.xs
@@ -1039,7 +1039,7 @@ sharedsv_array_mg_FETCHSIZE(pTHX_ SV *sv, MAGIC *mg)
val = av_len((AV*) ssv);
} else {
/* Not actually defined by tie API but ... */
- val = HvKEYS((HV*) ssv);
+ val = HvUSEDKEYS((HV*) ssv);
}
SHARED_RELEASE;
return (val);
diff --git a/doop.c b/doop.c
index 4e0d9e398c..c11555f2b6 100644
--- a/doop.c
+++ b/doop.c
@@ -1262,7 +1262,7 @@ Perl_do_kv(pTHX)
dTARGET;
if (! SvTIED_mg((const SV *)keys, PERL_MAGIC_tied) ) {
- i = HvKEYS(keys);
+ i = HvUSEDKEYS(keys);
}
else {
i = 0;
@@ -1273,7 +1273,7 @@ Perl_do_kv(pTHX)
RETURN;
}
- EXTEND(SP, HvKEYS(keys) * (dokeys + dovalues));
+ EXTEND(SP, HvUSEDKEYS(keys) * (dokeys + dovalues));
PUTBACK; /* hv_iternext and hv_iterval might clobber stack_sp */
while ((entry = hv_iternext(keys))) {
diff --git a/dump.c b/dump.c
index 4e98394848..32e7596c63 100644
--- a/dump.c
+++ b/dump.c
@@ -1830,13 +1830,13 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
break;
case SVt_PVHV:
Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
- if (HvARRAY(sv) && HvKEYS(sv)) {
+ if (HvARRAY(sv) && HvUSEDKEYS(sv)) {
/* Show distribution of HEs in the ARRAY */
int freq[200];
#define FREQ_MAX ((int)(sizeof freq / sizeof freq[0] - 1))
int i;
int max = 0;
- U32 pow2 = 2, keys = HvKEYS(sv);
+ U32 pow2 = 2, keys = HvUSEDKEYS(sv);
NV theoret, sum = 0;
PerlIO_printf(file, " (");
@@ -1878,13 +1878,13 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
}
while ((keys = keys >> 1))
pow2 = pow2 << 1;
- theoret = HvKEYS(sv);
+ theoret = HvUSEDKEYS(sv);
theoret += theoret * (theoret-1)/pow2;
PerlIO_putc(file, '\n');
Perl_dump_indent(aTHX_ level, file, " hash quality = %.1"NVff"%%", theoret/sum*100);
}
PerlIO_putc(file, '\n');
- Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)HvKEYS(sv));
+ Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)HvUSEDKEYS(sv));
Perl_dump_indent(aTHX_ level, file, " FILL = %"IVdf"\n", (IV)HvFILL(sv));
Perl_dump_indent(aTHX_ level, file, " MAX = %"IVdf"\n", (IV)HvMAX(sv));
Perl_dump_indent(aTHX_ level, file, " RITER = %"IVdf"\n", (IV)HvRITER_get(sv));
diff --git a/ext/B/B.xs b/ext/B/B.xs
index c1071c5e33..627f85178b 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -1959,12 +1959,12 @@ void
HvARRAY(hv)
B::HV hv
PPCODE:
- if (HvKEYS(hv) > 0) {
+ if (HvUSEDKEYS(hv) > 0) {
SV *sv;
char *key;
I32 len;
(void)hv_iterinit(hv);
- EXTEND(sp, HvKEYS(hv) * 2);
+ EXTEND(sp, HvUSEDKEYS(hv) * 2);
while ((sv = hv_iternextsv(hv, &key, &len))) {
mPUSHp(key, len);
PUSHs(make_sv_object(aTHX_ sv));
diff --git a/hv.c b/hv.c
index 5e96013279..390eba8be8 100644
--- a/hv.c
+++ b/hv.c
@@ -800,7 +800,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
if (!counter) { /* initial entry? */
} else if (xhv->xhv_keys > xhv->xhv_max) {
- /* Use only the old HvKEYS(hv) > HvMAX(hv) condition to limit
+ /* Use only the old HvUSEDKEYS(hv) > HvMAX(hv) condition to limit
bucket splits on a rehashed hash, as we're not going to
split it again, and if someone is lucky (evil) enough to
get all the keys in one list they could exhaust our memory
@@ -1623,7 +1623,7 @@ S_clear_placeholders(pTHX_ HV *hv, U32 items)
if (--items == 0) {
/* Finished. */
HvTOTALKEYS(hv) -= (IV)HvPLACEHOLDERS_get(hv);
- if (HvKEYS(hv) == 0)
+ if (HvUSEDKEYS(hv) == 0)
HvHASKFLAGS_off(hv);
HvPLACEHOLDERS_set(hv, 0);
return;
@@ -2003,7 +2003,7 @@ S_hv_auxinit(HV *hv) {
=for apidoc hv_iterinit
Prepares a starting point to traverse a hash table. Returns the number of
-keys in the hash (i.e. the same as C<HvKEYS(hv)>). The return value is
+keys in the hash (i.e. the same as C<HvUSEDKEYS(hv)>). The return value is
currently only meaningful for hashes without tie magic.
NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of
@@ -2817,7 +2817,7 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
if (!next) { /* initial entry? */
- } else if (xhv->xhv_keys > xhv->xhv_max /* HvKEYS(hv) > HvMAX(hv) */) {
+ } else if (xhv->xhv_keys > xhv->xhv_max /* HvUSEDKEYS(hv) > HvMAX(hv) */) {
hsplit(PL_strtab);
}
}
diff --git a/mg.c b/mg.c
index d061c51d7f..cfa319728f 100644
--- a/mg.c
+++ b/mg.c
@@ -1732,7 +1732,7 @@ Perl_magic_getnkeys(pTHX_ SV *sv, MAGIC *mg)
if (hv) {
(void) hv_iterinit(hv);
if (! SvTIED_mg((const SV *)hv, PERL_MAGIC_tied))
- i = HvKEYS(hv);
+ i = HvUSEDKEYS(hv);
else {
while (hv_iternext(hv))
i++;
diff --git a/mro.c b/mro.c
index 30be935157..118541723b 100644
--- a/mro.c
+++ b/mro.c
@@ -666,7 +666,7 @@ S_mro_clean_isarev(pTHX_ HV * const isa, const char * const name,
if(svp) {
HV * const isarev = (HV *)*svp;
(void)hv_delete(isarev, name, len, G_DISCARD);
- if(!HvARRAY(isarev) || !HvKEYS(isarev))
+ if(!HvARRAY(isarev) || !HvUSEDKEYS(isarev))
(void)hv_delete(PL_isarev, key, klen, G_DISCARD);
}
}
diff --git a/pp.c b/pp.c
index d91faa4868..0069fbabcf 100644
--- a/pp.c
+++ b/pp.c
@@ -6339,7 +6339,7 @@ PP(pp_boolkeys)
}
}
- XPUSHs(boolSV(HvKEYS(hv) != 0));
+ XPUSHs(boolSV(HvUSEDKEYS(hv) != 0));
RETURN;
}
diff --git a/pp_hot.c b/pp_hot.c
index f8a61cbdb2..531a33e219 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -999,7 +999,7 @@ PP(pp_aassign)
|| SvMAGICAL(sv)
|| ! (SvTYPE(sv) == SVt_PVAV || SvTYPE(sv) == SVt_PVHV)
|| (SvTYPE(sv) == SVt_PVAV && AvFILL((AV*)sv) != -1)
- || (SvTYPE(sv) == SVt_PVHV && HvKEYS((HV*)sv) != 0)
+ || (SvTYPE(sv) == SVt_PVHV && HvUSEDKEYS((HV*)sv) != 0)
)
) {
EXTEND_MORTAL(lastrelem - firstrelem + 1);
diff --git a/t/benchmark/rt26188-speed-up-keys-on-empty-hash.t b/t/benchmark/rt26188-speed-up-keys-on-empty-hash.t
index 155aa3f887..47703829a0 100644
--- a/t/benchmark/rt26188-speed-up-keys-on-empty-hash.t
+++ b/t/benchmark/rt26188-speed-up-keys-on-empty-hash.t
@@ -86,5 +86,5 @@ __END__
/* quick bailout if the hash is empty anyway.
I don't know if placeholders are included in the KEYS count, so a defensive check
*/
- if (! HvKEYS(hv) && !(flags & HV_ITERNEXT_WANTPLACEHOLDERS) )
+ if (! HvUSEDKEYS(hv) && !(flags & HV_ITERNEXT_WANTPLACEHOLDERS) )
return NULL;