From 8089fdadf0e95640059bfe627c44524bf68d459a Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 16 Jan 2026 17:11:43 +0900 Subject: [PATCH] bigint.c: inline usub_inplace() at call site Function was only called once and contained just 2 lines of code. Inlining directly reduces code size and improves clarity. Co-authored-by: Claude --- mrbgems/mruby-bigint/core/bigint.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/mrbgems/mruby-bigint/core/bigint.c b/mrbgems/mruby-bigint/core/bigint.c index d2dfde635..2f138c110 100644 --- a/mrbgems/mruby-bigint/core/bigint.c +++ b/mrbgems/mruby-bigint/core/bigint.c @@ -400,17 +400,6 @@ usub(mpz_t *z, mpz_t *y, mpz_t *x) z->sz = digits(z); } -/* In-place unsigned subtraction: a -= b */ -/* Precondition: abs(a) >= abs(b), no allocation needed */ -static void -usub_inplace(mpz_t *a, mpz_t *b) -{ - /* a->sz >= b->sz is guaranteed by precondition */ - mpn_sub(a->p, a->p, a->sz, b->p, b->sz); - /* Normalize: find actual size after subtraction */ - a->sz = digits(a); -} - /* compare abs(x) and abs(y) */ static int ucmp(mpz_t *y, mpz_t *x) @@ -605,7 +594,8 @@ mpz_sub(mpz_ctx_t *ctx, mpz_t *z, mpz_t *x, mpz_t *y) { /* In-place optimization: z == x, both positive, x >= y */ if (z == x && x->sn > 0 && y->sn > 0 && ucmp(x, y) >= 0) { - usub_inplace(x, y); + mpn_sub(x->p, x->p, x->sz, y->p, y->sz); + x->sz = digits(x); if (x->sz == 0) x->sn = 0; return; }