diff options
-rw-r--r-- | dump.c | 13 | ||||
-rw-r--r-- | hv.c | 6 |
2 files changed, 12 insertions, 7 deletions
@@ -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)) { @@ -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; |