aboutsummaryrefslogtreecommitdiff
path: root/builtins/integers.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-05 10:31:35 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-05 10:31:35 -0400
commit8d41b2b1fbe3edc870b9456b991446aaa8b3dddd (patch)
tree7c8be033455da86d6be0f6ec9f17451fe41494ed /builtins/integers.c
parentd3c4f613ac9bc711858bc1c74c8232a7d86666dc (diff)
Do the extremely obvious optimization of checking if two pieces of data
are at the same location before bothering to compare them
Diffstat (limited to 'builtins/integers.c')
-rw-r--r--builtins/integers.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtins/integers.c b/builtins/integers.c
index d9361cf4..a147df72 100644
--- a/builtins/integers.c
+++ b/builtins/integers.c
@@ -40,13 +40,13 @@ public Text_t Int$as_text(const Int_t *i, bool colorize, const TypeInfo *type) {
public int32_t Int$compare(const Int_t *x, const Int_t *y, const TypeInfo *type) {
(void)type;
if (__builtin_expect(((x->small | y->small) & 1) == 0, 0))
- return mpz_cmp(*x->big, *y->big);
+ return x->big == y->big ? 0 : mpz_cmp(*x->big, *y->big);
return (x->small > y->small) - (x->small < y->small);
}
public int32_t Int$compare_value(const Int_t x, const Int_t y) {
if (__builtin_expect(((x.small | y.small) & 1) == 0, 0))
- return mpz_cmp(*x.big, *y.big);
+ return x.big == y.big ? 0 : mpz_cmp(*x.big, *y.big);
return (x.small > y.small) - (x.small < y.small);
}