Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(viewport): use isolate_lowest_one for fenwick index math

Steven Enamakeld340fa77f3cd
diff --git a/crates/openhuman-tui/src/viewport.rs b/crates/openhuman-tui/src/viewport.rs
index e02769b376..716e9b8321 100644
--- a/crates/openhuman-tui/src/viewport.rs
+++ b/crates/openhuman-tui/src/viewport.rs
@@ -48,7 +48,7 @@ impl HeightIndex {
}
fn push(&mut self, height: usize) {
let index = self.tree.len() + 1;
- let start = index - (index & index.wrapping_neg());
+ let start = index - index.isolate_lowest_one();
self.tree.push(height + self.total - self.prefix(start));
self.total += height;
}
@@ -57,7 +57,7 @@ impl HeightIndex {
let mut index = index + 1;
while index <= self.tree.len() {
self.tree[index - 1] = self.tree[index - 1] - before + after;
- index += index & index.wrapping_neg();
+ index += index.isolate_lowest_one();
}
}
fn containing(&self, row: usize) -> usize {