优化: 资源消耗优化,发布 v0.2.1
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user