diff options
author | Nicholas Clark <nick@ccl4.org> | 2021-08-22 08:35:30 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2021-08-23 08:29:09 +0000 |
commit | e2737abbb702a05e83f4aa2486a941ac3964446a (patch) | |
tree | 08bd941b725574c8755d7906889bebad14a88670 /pp_hot.c | |
parent | 77745d701ca519f67def45b50e91f34685ee92e3 (diff) | |
download | perl-e2737abbb702a05e83f4aa2486a941ac3964446a.tar.gz |
Pre-extend hashes in list assignment before assigning to them.
We know how many pairs of keys/values are on the stack, so pre-extend the
hash to the appropriate size, instead of letting the hash needlessly re-size
one or more times during the assignment loop.
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2571,6 +2571,11 @@ PP(pp_aassign) if (SvRMAGICAL(hash) || HvUSEDKEYS(hash)) hv_clear(hash); + /* "nelems" was converted to the number of pairs earlier. */ + if (nelems > PERL_HASH_DEFAULT_HvMAX) { + hv_ksplit(hash, nelems); + } + /* now assign the keys and values to the hash */ dirty_tmps = FALSE; |