mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Use a cache for icons
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user