This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Pre-extend hashes in list assignment before assigning to them.
[perl5.git] / pp_hot.c
index 6e7e384..17683ff 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -2571,6 +2571,11 @@ PP(pp_aassign)
             if (SvRMAGICAL(hash) || HvUSEDKEYS(hash))
                 hv_clear(hash);
 
             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;
             /* now assign the keys and values to the hash */
 
             dirty_tmps = FALSE;