summaryrefslogtreecommitdiff
path: root/hv.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-08-20 15:20:13 +0000
committerNicholas Clark <nick@ccl4.org>2021-10-11 11:30:25 +0000
commit94ee6ed79dbca73d0345b745534477e4017fb990 (patch)
tree2743d0b040c1dce45f0a921cccbaf3c324b71509 /hv.h
parent36149847e29e423be58d70fad50d9908be1d0373 (diff)
downloadperl-94ee6ed79dbca73d0345b745534477e4017fb990.tar.gz
Split the XPVHV body into two variants "normal" and "with aux"
Default to the smaller body, and switch to the larger body if we need to allocate a C<struct xpvhv_aux> (eg need an iterator). This restores the previous small size optimisation for hashes used as objects.
Diffstat (limited to 'hv.h')
-rw-r--r--hv.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/hv.h b/hv.h
index 285a004a5f..c7aeb7de57 100644
--- a/hv.h
+++ b/hv.h
@@ -137,6 +137,13 @@ struct xpvhv {
union _xmgu xmg_u;
STRLEN xhv_keys; /* total keys, including placeholders */
STRLEN xhv_max; /* subscript of last element of xhv_array */
+};
+
+struct xpvhv_with_aux {
+ HV *xmg_stash; /* class package */
+ union _xmgu xmg_u;
+ STRLEN xhv_keys; /* total keys, including placeholders */
+ STRLEN xhv_max; /* subscript of last element of xhv_array */
struct xpvhv_aux xhv_aux;
};
@@ -264,7 +271,7 @@ See L</hv_fill>.
#define HvMAX(hv) ((XPVHV*) SvANY(hv))->xhv_max
/* This quite intentionally does no flag checking first. That's your
responsibility. */
-#define HvAUX(hv) (&(((XPVHV*) SvANY(hv))->xhv_aux))
+#define HvAUX(hv) (&(((struct xpvhv_with_aux*) SvANY(hv))->xhv_aux))
#define HvRITER(hv) (*Perl_hv_riter_p(aTHX_ MUTABLE_HV(hv)))
#define HvEITER(hv) (*Perl_hv_eiter_p(aTHX_ MUTABLE_HV(hv)))
#define HvRITER_set(hv,r) Perl_hv_riter_set(aTHX_ MUTABLE_HV(hv), r)