Skip to content

Commit 930afa1

Browse files
committed
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.
1 parent b0c9286 commit 930afa1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bignum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ rb_big_realloc(VALUE big, size_t len)
30483048
if (BIGNUM_LEN(big) == 0) {
30493049
RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len);
30503050
}
3051-
else {
3051+
else if (BIGNUM_LEN(big) < len) {
30523052
REALLOC_N(RBIGNUM(big)->as.heap.digits, BDIGIT, len);
30533053
}
30543054
}

0 commit comments

Comments
 (0)