diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-02-21 17:09:29 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-02-26 16:00:19 +0100 |
commit | 0ca1b5c32d8dd81962d7080ae0a761edace1603e (patch) | |
tree | e0a2b3e275662d8ffb00ea5df1d231fface39fc6 /hv.c | |
parent | 3a015b94b043d8b0450eec2bb532e12c91b4ea52 (diff) | |
download | perl-0ca1b5c32d8dd81962d7080ae0a761edace1603e.tar.gz |
Move the call to hv_clear_placeholders() from hsplit() to hv_common().
The relevant code calls Perl_hv_clear_placeholders() at split time, if there
are still placeholders left over from a (previously) restricted hash.
There are two callers to S_hsplit(), one from the regular HV code, and one
from the shared string table code. As the shared string table can't contain
placeholders, only the other call site could trigger this condition, so move
the code there. This simplifies S_hsplit(), and will make splitting the
shared string table marginally faster.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -796,6 +796,16 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */ if ( DO_HSPLIT(xhv) ) { + /* 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. */ + if (HvPLACEHOLDERS_get(hv) && !SvREADONLY(hv)) { + /* Can make this clear any placeholders first for non-restricted + hashes, even though Storable rebuilds restricted hashes by + putting in all the placeholders (first) before turning on the + readonly flag, because Storable always pre-splits the hash. */ + hv_clear_placeholders(hv); + } hsplit(hv); } @@ -1100,14 +1110,6 @@ S_hsplit(pTHX_ HV *hv) /*PerlIO_printf(PerlIO_stderr(), "hsplit called for %p which had %d\n", (void*)hv, (int) oldsize);*/ - if (HvPLACEHOLDERS_get(hv) && !SvREADONLY(hv)) { - /* Can make this clear any placeholders first for non-restricted hashes, - even though Storable rebuilds restricted hashes by putting in all the - placeholders (first) before turning on the readonly flag, because - Storable always pre-splits the hash. */ - hv_clear_placeholders(hv); - } - PL_nomemok = TRUE; Renew(a, PERL_HV_ARRAY_ALLOC_BYTES(newsize) + (SvOOK(hv) ? sizeof(struct xpvhv_aux) : 0), char); |