mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-09 20:00:11 -06:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e49aaf0072 |
+2
-1
File diff suppressed because one or more lines are too long
@@ -58,6 +58,23 @@ mod tests {
|
|||||||
assert!(t.rows.iter().all(|r| r.len() <= 64), "a row grew past the column cap");
|
assert!(t.rows.iter().all(|r| r.len() <= 64), "a row grew past the column cap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn insert_covered_skips_full_rows_without_walking_them() {
|
||||||
|
// 50,000 spanning cells over a 50,000-cell row: each walked the row below to its grid
|
||||||
|
// column before finding it full (billions of steps). A full row is now skipped at once.
|
||||||
|
let n = 50_000;
|
||||||
|
let mut t = FTable {
|
||||||
|
rows: vec![vec![Cell { rowspan: 2, ..Default::default() }; n], vec![Cell::default(); n]],
|
||||||
|
widths: Vec::new(),
|
||||||
|
borderless: false,
|
||||||
|
};
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
t.insert_covered();
|
||||||
|
assert!(start.elapsed() < std::time::Duration::from_secs(10), "{:?}", start.elapsed());
|
||||||
|
assert_eq!(t.rows[1].len(), n, "a full row takes no covered cell");
|
||||||
|
assert!(t.rows[1].iter().all(|c| !c.covered));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn base64_round_trip() {
|
fn base64_round_trip() {
|
||||||
for data in [&b""[..], b"f", b"fo", b"foo", b"foob", b"fooba", b"foobar", &[0, 255, 128, 7]] {
|
for data in [&b""[..], b"f", b"fo", b"foo", b"foob", b"fooba", b"foobar", &[0, 255, 128, 7]] {
|
||||||
|
|||||||
@@ -418,6 +418,11 @@ impl FTable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let Some(row) = self.rows.get_mut(r + k) else { break };
|
let Some(row) = self.rows.get_mut(r + k) else { break };
|
||||||
|
// A full row takes no covered cell: checked before it is walked, so a
|
||||||
|
// wide row isn't scanned for every span above it.
|
||||||
|
if row.len() >= 64 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Find the index in that row at grid column `g`.
|
// Find the index in that row at grid column `g`.
|
||||||
let mut x = 0usize;
|
let mut x = 0usize;
|
||||||
let mut at = row.len();
|
let mut at = row.len();
|
||||||
@@ -428,9 +433,7 @@ impl FTable {
|
|||||||
}
|
}
|
||||||
x += cc.colspan.clamp(1, 63) as usize;
|
x += cc.colspan.clamp(1, 63) as usize;
|
||||||
}
|
}
|
||||||
if row.len() < 64 {
|
row.insert(at, Cell { colspan: span as u32, covered: true, ..Default::default() });
|
||||||
row.insert(at, Cell { colspan: span as u32, covered: true, ..Default::default() });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g += span;
|
g += span;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user