From a2bcc741ff68c1a34395e0db05b66f503e3d98f1 Mon Sep 17 00:00:00 2001 From: Arne Goedeke <el@laramies.com> Date: Thu, 15 Nov 2012 07:11:30 +0100 Subject: [PATCH] mapping: optimize equal_p for disjunct type fields --- src/mapping.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mapping.c b/src/mapping.c index 170446cf59..42601813ca 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -121,6 +121,10 @@ static INLINE int check_type_contains(TYPE_FIELD types, const struct svalue * s) return (TYPEOF(*s) == PIKE_T_OBJECT || types & (BIT_OBJECT|(1 << TYPEOF(*s)))); } +static INLINE int check_type_overlaps(TYPE_FIELD t1, TYPE_FIELD t2) { + return t1 & t2 || (t1|t2) & BIT_OBJECT; +} + #ifdef PIKE_DEBUG /** This function checks that the type field isn't lacking any bits. @@ -1880,6 +1884,9 @@ PMOD_EXPORT int mapping_equal_p(struct mapping *a, struct mapping *b, struct pro if(m_sizeof(a) != m_sizeof(b)) return 0; + if (!check_type_overlaps(a->data->ind_types, b->data->ind_types) || + !check_type_overlaps(a->data->val_types, b->data->val_types)) return 0; + curr.pointer_a = a; curr.pointer_b = b; curr.next = p; -- GitLab