alloy-rs / alloy-rs/ruint

`algorithms/div/knuth`: Can we re-use `r` here somehow? The problem is we

Abierto
#631 0 comentarios 0 reacciones 1 asignado Reclamado por @decofe Ver en GitHub
optimize tracker
Lenguaje dominante
Rust
Estrellas
225
Forks
70
Merge medio
16 h 54 min
PR fusionados (30 d)
8

Descripción

*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)*

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.