diff options
author | Michael Witten <mfwitten@gmail.com> | 2011-03-19 17:34:58 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-03-19 17:34:58 -0700 |
commit | 5b430b36d8e956d2af13b8b933400cf0c1c707f2 (patch) | |
tree | f1070d0df6b1f1aefe2d4b4d1889dab3fa61d9f2 | |
parent | a4fce065dba71ea958501c234d983bfbe7d445a0 (diff) | |
download | perl-5b430b36d8e956d2af13b8b933400cf0c1c707f2.tar.gz |
Clean: Move old comment to proper location
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.
-rw-r--r-- | hv.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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); } } |