summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dump.c13
-rw-r--r--hv.c6
2 files changed, 12 insertions, 7 deletions
diff --git a/dump.c b/dump.c
index b5998f9b82..354cd57a9f 100644
--- a/dump.c
+++ b/dump.c
@@ -1882,20 +1882,22 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
}
}
break;
- case SVt_PVHV:
+ case SVt_PVHV: {
+ U32 usedkeys;
if (SvOOK(sv)) {
struct xpvhv_aux *const aux = HvAUX(sv);
Perl_dump_indent(aTHX_ level, file, " AUX_FLAGS = %"UVuf"\n",
(UV)aux->xhv_aux_flags);
}
Perl_dump_indent(aTHX_ level, file, " ARRAY = 0x%"UVxf, PTR2UV(HvARRAY(sv)));
- if (HvARRAY(sv) && HvUSEDKEYS(sv)) {
+ usedkeys = HvUSEDKEYS(sv);
+ if (HvARRAY(sv) && usedkeys) {
/* 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 = HvUSEDKEYS(sv);
+ U32 pow2 = 2, keys = usedkeys;
NV theoret, sum = 0;
PerlIO_printf(file, " (");
@@ -1937,13 +1939,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 = HvUSEDKEYS(sv);
+ theoret = usedkeys;
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)HvUSEDKEYS(sv));
+ Perl_dump_indent(aTHX_ level, file, " KEYS = %"IVdf"\n", (IV)usedkeys);
{
STRLEN count = 0;
HE **ents = HvARRAY(sv);
@@ -2116,6 +2118,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
}
}
break;
+ } /* case SVt_PVHV */
case SVt_PVCV:
if (CvAUTOLOAD(sv)) {
diff --git a/hv.c b/hv.c
index 91d4c39fa9..9d80659853 100644
--- a/hv.c
+++ b/hv.c
@@ -1625,8 +1625,10 @@ S_clear_placeholders(pTHX_ HV *hv, U32 items)
if (--items == 0) {
/* Finished. */
- HvTOTALKEYS(hv) -= (IV)HvPLACEHOLDERS_get(hv);
- if (HvUSEDKEYS(hv) == 0)
+ I32 placeholders = HvPLACEHOLDERS_get(hv);
+ HvTOTALKEYS(hv) -= (IV)placeholders;
+ /* HvUSEDKEYS expanded */
+ if ((HvTOTALKEYS(hv) - placeholders) == 0)
HvHASKFLAGS_off(hv);
HvPLACEHOLDERS_set(hv, 0);
return;