From 8d41b2b1fbe3edc870b9456b991446aaa8b3dddd Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 5 Sep 2024 10:31:35 -0400 Subject: Do the extremely obvious optimization of checking if two pieces of data are at the same location before bothering to compare them --- builtins/range.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'builtins/range.c') diff --git a/builtins/range.c b/builtins/range.c index d170e6b7..068d8cea 100644 --- a/builtins/range.c +++ b/builtins/range.c @@ -18,6 +18,7 @@ static int32_t Range$compare(const Range_t *x, const Range_t *y, const TypeInfo *type) { (void)type; + if (x == y) return 0; int32_t diff = Int$compare(&x->first, &y->first, &$Int); if (diff != 0) return diff; diff = Int$compare(&x->last, &y->last, &$Int); @@ -28,6 +29,7 @@ static int32_t Range$compare(const Range_t *x, const Range_t *y, const TypeInfo static bool Range$equal(const Range_t *x, const Range_t *y, const TypeInfo *type) { (void)type; + if (x == y) return true; return Int$equal(&x->first, &y->first, &$Int) && Int$equal(&x->last, &y->last, &$Int) && Int$equal(&x->step, &y->step, &$Int); } -- cgit v1.2.3