summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2025-11-03 15:48:28 -0800
committerJohn Hawthorn <john@hawthorn.email>2025-12-05 06:21:17 -0800
commit930afa1c7ba747658cc4253c2cb6a367d7a6a36b (patch)
tree3a9df89c2a1cc0fe4f8aa77651bdc62c8e4f04d5
parentb0c9286d98929db56514d8009040fe206b3d310f (diff)
Never shrink bignum on realloc
As far as I can tell, this only ever shrinks by one, and it's really not worth the expensive realloc for that.
-rw-r--r--bignum.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bignum.c b/bignum.c
index 9e8d6a91f1..8d3eac8e0a 100644
--- a/bignum.c
+++ b/bignum.c
@@ -3048,7 +3048,7 @@ rb_big_realloc(VALUE big, size_t len)
if (BIGNUM_LEN(big) == 0) {
RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len);
}
- else {
+ else if (BIGNUM_LEN(big) < len) {
REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len);
}
}