summaryrefslogtreecommitdiff
path: root/hv.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-03-11 11:42:32 +0000
committerNicholas Clark <nick@ccl4.org>2013-05-29 10:52:50 +0200
commit9faf471aadb0009c0def1e2e9ab174082632af3b (patch)
tree83cb48c21bb39e29bcc82690c0f5b8caefa47d8d /hv.h
parent99f57afc36ebadbe790958225afc2a70c73dd64a (diff)
downloadperl-9faf471aadb0009c0def1e2e9ab174082632af3b.tar.gz
Cache HvFILL() for larger hashes, and update on insertion/deletion.
This avoids HvFILL() being O(n) for large n on large hashes, but also avoids storing the value of HvFILL() in smaller hashes (ie a memory overhead on every single object built using a hash.)
Diffstat (limited to 'hv.h')
-rw-r--r--hv.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/hv.h b/hv.h
index 2eea4779c1..6ebd5d56d3 100644
--- a/hv.h
+++ b/hv.h
@@ -117,6 +117,7 @@ struct xpvhv_aux {
U32 xhv_last_rand; /* last random value for hash traversal,
used to detect each() after insert for warnings */
#endif
+ U32 xhv_fill_lazy;
};
/* hash structure: */
@@ -239,7 +240,7 @@ C<SV*>.
# define Nullhv Null(HV*)
#endif
#define HvARRAY(hv) ((hv)->sv_u.svu_hash)
-#define HvFILL(hv) Perl_hv_fill(aTHX_ (const HV *)(hv))
+#define HvFILL(hv) Perl_hv_fill(aTHX_ MUTABLE_HV(hv))
#define HvMAX(hv) ((XPVHV*) SvANY(hv))->xhv_max
/* This quite intentionally does no flag checking first. That's your
responsibility. */