Skip to content

Commit 76c48c2

Browse files
Mana (마나)claude
andcommitted
perf: static logo lines, eliminate per-frame format!() in header
- LOGO array includes leading space in each line (pre-formatted) - render_header_full borrows static strings directly instead of format!(" {}", line) per logo line per frame - Shared logo_style computed once instead of per-line Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 011fd04 commit 76c48c2

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

scalex-cli/src/dash/ui.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ pub fn render(f: &mut Frame, app: &App) {
7676
// ---------------------------------------------------------------------------
7777

7878
/// ASCII art logo for full-size header (6 lines)
79+
/// Pre-formatted logo lines with leading space — avoids per-frame format!(" {}", line).
7980
const LOGO: [&str; 6] = [
80-
r"███████╗ ██████╗ █████╗ ██╗ ███████╗██╗ ██╗",
81-
r"██╔════╝██╔════╝██╔══██╗██║ ██╔════╝╚██╗██╔╝",
82-
r"███████╗██║ ███████║██║ █████╗ ╚███╔╝ ",
83-
r"╚════██║██║ ██╔══██║██║ ██╔══╝ ██╔██╗ ",
84-
r"███████║╚██████╗██║ ██║███████╗███████╗██╔╝ ██╗",
85-
r"╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝",
81+
" ███████╗ ██████╗ █████╗ ██╗ ███████╗██╗ ██╗",
82+
" ██╔════╝██╔════╝██╔══██╗██║ ██╔════╝╚██╗██╔╝",
83+
" ███████╗██║ ███████║██║ █████╗ ╚███╔╝ ",
84+
" ╚════██║██║ ██╔══██║██║ ██╔══╝ ██╔██╗ ",
85+
" ███████║╚██████╗██║ ██║███████╗███████╗██╔╝ ██╗",
86+
" ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝",
8687
];
8788

8889
fn render_header(f: &mut Frame, app: &App, area: Rect) {
@@ -150,16 +151,12 @@ fn render_header_full(
150151

151152
// Left: ASCII art logo
152153
if show_logo && cols.len() > 1 {
154+
let logo_style = Style::default()
155+
.fg(theme::BRIGHT_ORANGE)
156+
.add_modifier(Modifier::BOLD);
153157
let logo_lines: Vec<Line> = LOGO
154158
.iter()
155-
.map(|line| {
156-
Line::from(Span::styled(
157-
format!(" {}", line),
158-
Style::default()
159-
.fg(theme::BRIGHT_ORANGE)
160-
.add_modifier(Modifier::BOLD),
161-
))
162-
})
159+
.map(|line| Line::from(Span::styled(*line, logo_style)))
163160
.collect();
164161
let logo_para = Paragraph::new(logo_lines).style(Style::default().bg(theme::BG_HARD));
165162
f.render_widget(logo_para, cols[0]);

0 commit comments

Comments
 (0)