mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
runewidth.StringWidth is an expensive call, even if the input string is pure ASCII. Improve this by providing a wrapper that short-circuits the call to len if the input is ASCII. Benchmark results show that for non-ASCII strings it makes no noticable difference, but for ASCII strings it provides a more than 200x speedup. BenchmarkStringWidthAsciiOriginal-10 718135 1637 ns/op BenchmarkStringWidthAsciiOptimized-10 159197538 7.545 ns/op BenchmarkStringWidthNonAsciiOriginal-10 486290 2391 ns/op BenchmarkStringWidthNonAsciiOptimized-10 502286 2383 ns/op |
||
|---|---|---|
| .. | ||
| authors | ||
| graph | ||
| icons | ||
| branches.go | ||
| branches_test.go | ||
| commits.go | ||
| commits_test.go | ||
| files.go | ||
| files_test.go | ||
| item_operations.go | ||
| reflog_commits.go | ||
| remote_branches.go | ||
| remotes.go | ||
| stash_entries.go | ||
| status.go | ||
| submodules.go | ||
| suggestions.go | ||
| tags.go | ||
| working_tree.go | ||
| worktrees.go | ||