diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-02-21 19:45:38 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-02-26 16:00:19 +0100 |
commit | adf6906bf1b434ce6de8a74bee3758cc5bd83b7a (patch) | |
tree | 9150d021ef6cc30ff3251184cf20485ac0d3a04e /hv.c | |
parent | 0df056163a5c186d5ef583804a92195aeb095201 (diff) | |
download | perl-adf6906bf1b434ce6de8a74bee3758cc5bd83b7a.tar.gz |
Pass the current and desired hash sizes to S_hsplit().
Whilst this is slightly more work for its existing two callers, it will
permit Perl_hv_ksplit() to also call it.
Use STRLEN for the parameters, and change a local variable from I32 to
STRLEN to match.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -796,6 +796,8 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */ if ( DO_HSPLIT(xhv) ) { + const STRLEN oldsize = xhv->xhv_max + 1; + /* This logic was in S_hsplit, but as the shared string table can't contain placeholders, and we are the only other caller of S_hsplit, it could only trigger from this callsite. So move it here. */ @@ -806,7 +808,7 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, readonly flag, because Storable always pre-splits the hash. */ hv_clear_placeholders(hv); } - hsplit(hv); + hsplit(hv, oldsize, oldsize * 2); } if (return_svp) { @@ -1095,13 +1097,10 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, } STATIC void -S_hsplit(pTHX_ HV *hv) +S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize) { dVAR; - XPVHV* const xhv = (XPVHV*)SvANY(hv); - const I32 oldsize = (I32) xhv->xhv_max+1; /* HvMAX(hv)+1 (sick) */ - I32 newsize = oldsize * 2; - I32 i; + STRLEN i; char *a = (char*) HvARRAY(hv); HE **aep; @@ -1123,7 +1122,7 @@ S_hsplit(pTHX_ HV *hv) PL_nomemok = FALSE; Zero(&a[oldsize * sizeof(HE*)], (newsize-oldsize) * sizeof(HE*), char); /* zero 2nd half*/ - xhv->xhv_max = --newsize; /* HvMAX(hv) = --newsize */ + HvMAX(hv) = --newsize; HvARRAY(hv) = (HE**) a; aep = (HE**)a; @@ -2672,7 +2671,8 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags) xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */ if (!next) { /* initial entry? */ } else if ( DO_HSPLIT(xhv) ) { - hsplit(PL_strtab); + const STRLEN oldsize = xhv->xhv_max + 1; + hsplit(PL_strtab, oldsize, oldsize * 2); } } |