mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
b7593cde15
Add fast path for multiplying numbers of form 2^n - 1 (all bits set). Uses algebraic identities: - (2^n - 1) * (2^m - 1) = 2^(n+m) - 2^n - 2^m + 1 - (2^n - 1) * y = (y << n) - y These are O(n) operations instead of O(n^1.585) for Karatsuba. Fuzzing test cases using all-ones patterns now complete in 0.01s instead of 13+ seconds. Also raises KARATSUBA_THRESHOLD from 8 to 32 for ~32% speedup on general large number multiplication. Co-authored-by: Claude <noreply@anthropic.com>