优化: 资源消耗优化,发布 v0.2.1

This commit is contained in:
2026-06-03 12:11:06 +08:00
parent 36aeef4bb7
commit 2c438e3bb9
9 changed files with 113 additions and 50 deletions

View File

@@ -21,6 +21,20 @@ func toWinPath(s string) string {
return strings.ReplaceAll(s, "/", "\\")
}
// --- 分隔线缓存 ---
var sepCache = make(map[int]string)
// sepRunes 返回 width 个 "─" 字符,结果按 width 缓存。
func sepRunes(w int) string {
if s, ok := sepCache[w]; ok {
return s
}
s := strings.Repeat("─", w)
sepCache[w] = s
return s
}
// --- 字符串宽度 ---
func stringWidth(s string) int {