From f135fc3eda9a34f9540486da433867b2698fa58c Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Thu, 10 Feb 2011 19:38:49 -0500 Subject: [PATCH] Slight optimization for scm_equal_p * libguile/eq.c (scm_equal_p): Move SCM_STRUCTP check within the default case of the SCM_TYP7 switch statement, for optimization. --- libguile/eq.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libguile/eq.c b/libguile/eq.c index 99b3488ad..11dce99a1 100644 --- a/libguile/eq.c +++ b/libguile/eq.c @@ -332,6 +332,14 @@ scm_equal_p (SCM x, SCM y) switch (SCM_TYP7 (x)) { default: + /* Check equality between structs of equal type (see cell-type test above). */ + if (SCM_STRUCTP (x)) + { + if (SCM_INSTANCEP (x)) + goto generic_equal; + else + return scm_i_struct_equalp (x, y); + } break; case scm_tc7_number: switch SCM_TYP16 (x) @@ -349,14 +357,6 @@ scm_equal_p (SCM x, SCM y) case scm_tc7_wvect: return scm_i_vector_equal_p (x, y); } - /* Check equality between structs of equal type (see cell-type test above). */ - if (SCM_STRUCTP (x)) - { - if (SCM_INSTANCEP (x)) - goto generic_equal; - else - return scm_i_struct_equalp (x, y); - } /* Otherwise just return false. Dispatching to the generic is the wrong thing here, as we can hit this case for any two objects of the same type that we