Skip to content

Commit

Permalink
perf(svg): Don't reparse the content
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 18, 2024
1 parent e59b184 commit 4d9c134
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/anstyle-svg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ impl Term {

let line_height = 18;
let height = styled_lines.len() * line_height;
let stripped = anstream::adapter::strip_str(ansi).to_string();
let max_width = stripped.lines().map(|s| s.width()).max().unwrap_or(20);
let max_width = styled_lines
.iter()
.map(|l| l.iter().map(|(_, t)| t.width()).fold(0, |p, n| p + n))
.max()
.unwrap_or(20);

use std::fmt::Write as _;
let mut buffer = String::new();
Expand Down

0 comments on commit 4d9c134

Please sign in to comment.