Clean: Move old comment to proper location
authorMichael Witten <mfwitten@gmail.com>
Sun, 20 Mar 2011 00:34:58 +0000 (17:34 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 20 Mar 2011 00:34:58 +0000 (17:34 -0700)
This:

  commit 0298d7b92741692bcf2e34c418a564332bb034e6:
  Date:   Tue May 31 10:40:01 2005 +0000

      Avoid updating a variable in a loop.
      Only calculate the number of links in a hash bucket chain if we really
      need it.

      p4raw-id: //depot/perl@24648

forgot to move a large comment to its new location; this new commit
fixes that.

hv.c

diff --git a/hv.c b/hv.c
index 5f9d901..ed5061f 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -800,6 +800,12 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
        xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
        if (!counter) {                         /* initial entry? */
        } else if (xhv->xhv_keys > xhv->xhv_max) {
+               /* Use only the old HvKEYS(hv) > HvMAX(hv) condition to limit
+                  bucket splits on a rehashed hash, as we're not going to
+                  split it again, and if someone is lucky (evil) enough to
+                  get all the keys in one list they could exhaust our memory
+                  as we repeatedly double the number of buckets on every
+                  entry. Linear search feels a less worse thing to do.  */
            hsplit(hv);
        } else if(!HvREHASH(hv)) {
            U32 n_links = 1;
@@ -808,12 +814,6 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
                n_links++;
 
            if (n_links > HV_MAX_LENGTH_BEFORE_SPLIT) {
-               /* Use only the old HvKEYS(hv) > HvMAX(hv) condition to limit
-                  bucket splits on a rehashed hash, as we're not going to
-                  split it again, and if someone is lucky (evil) enough to
-                  get all the keys in one list they could exhaust our memory
-                  as we repeatedly double the number of buckets on every
-                  entry. Linear search feels a less worse thing to do.  */
                hsplit(hv);
            }
        }