`algorithms/div/knuth`: Can we re-use `r` here somehow? The problem is we
- 主要言語
- Rust
- スター
- 225
- フォーク
- 70
- 平均マージ
- 16時間 54分
- マージ済み PR(30日)
- 8
説明
*On 2026-08-31 @decofe wrote in [`a9450b4`](https://github.com/alloy-rs/ruint/commit/a9450b499c03f259238c2955b9512de873a77e12) “chore: apply latest nightly rustfmt (#627)”:*
Can we re-use `r` here somehow? The problem is we
can not just shift the `r` or
borrow` because we need to accurately reproduce
the remainder and carry in the middle of a limb.
SAFETY: both slices have length `n`.
```rust
let (r, borrow) = r.overflowing_sub(u128::from(borrow));
numerator[j + n - 2] = DW::low(r);
numerator[j + n - 1] = DW::high(r);
borrow
} else {
// OPT: Can we re-use `r` here somehow? The problem is we
// can not just shift the `r` or
// `borrow` because we need to accurately reproduce
// the remainder and carry in the middle of a limb.
// SAFETY: both slices have length `n`.
let borrow = unsafe { submul_nx1(&mut numerator[j..j + n], divisor, q) };
let n2 = numerator.get(j + n).copied().unwrap_or_default();
borrow != n2
};
```
*From [`src/algorithms/div/knuth.rs:178`](https://github.com/alloy-rs/ruint/blob/a9450b499c03f259238c2955b9512de873a77e12/src/algorithms/div/knuth.rs#L178)*
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start in src/algorithms/div/knuth.rs around line 178 and read the surrounding Knuth division logic, including submul_nx1 and the handling of r, borrow, and n2. Determine whether r can be reused in the else branch without changing the accurately reproduced remainder or carry; done means the optimization is justified and preserves the existing division behavior.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- backend
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100