Use a cache for icons

This commit is contained in:
Kovid Goyal
2025-05-21 22:34:01 +05:30
parent f0537198e6
commit 60e701271f
2 changed files with 10 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ func (h *Handler) draw_screen() (err error) {
h.draw_search_bar(0)
}()
y := SEARCH_BAR_HEIGHT
y += h.draw_results(y, 4, matches, in_progress)
y += h.draw_results(y, 2, matches, in_progress)
return
}

View File

@@ -93,11 +93,20 @@ func (h *Handler) render_match_with_positions(text string, stop_at int, position
}
}
var icon_cache map[string]string
func icon_for(path string, x os.DirEntry) string {
if icon_cache == nil {
icon_cache = make(map[string]string, 512)
}
if ans := icon_cache[path]; ans != "" {
return ans
}
ans := icons.IconForFileWithMode(path, x.Type(), true)
if wcswidth.Stringwidth(ans) == 1 {
ans += " "
}
icon_cache[path] = ans
return ans
}