`x & 1` is a natural way to check the low bit of `std.bigint.BigInt x` but that allocates unlike the less natural `x.getDigit!uint(0) & 1`. Examples in Phobos of code that does this are `std.bigint.powmod(BigInt, BigInt, BigInt)` (a PR to fix it is pending) and `std.numeric.gcd!T(T, T)` when instantiated for `BigInt`. Adding special handling for `x & 1` will aside from helping naive uses also improve performance of generic templated code that operates on arbitrary number-like types.
@n8sh created dlang/phobos pull request #7544 "std.bigint.BigInt: special case x & 1 to avoid unnecessary allocation" fixing this issue: - Fix Issue 20980 - std.bigint.BigInt: special case x & 1 to avoid unnecessary allocation https://github.com/dlang/phobos/pull/7544
dlang/phobos pull request #7544 "std.bigint.BigInt: special case x & non-negative int to avoid unnecessary allocation" was merged into master: - 66876323c21dfbf9b187319de4e2a43c96a2a405 by Nathan Sashihara: Fix Issue 20980 - std.bigint.BigInt: special case x & non-negative int to avoid unnecessary allocation https://github.com/dlang/phobos/pull/7544