Performance tuning - eager rune array conversion

> wc -l /tmp/list2
     2594098 /tmp/list2

    > time cat /tmp/list2 | fzf-0.10.1-darwin_amd64 -fqwerty > /dev/null

    real    0m5.418s
    user    0m10.990s
    sys     0m1.302s

    > time cat /tmp/list2 | fzf-head -fqwerty > /dev/null

    real    0m4.862s
    user    0m6.619s
    sys     0m0.982s
This commit is contained in:
Junegunn Choi
2015-08-02 14:00:18 +09:00
parent 634670e3ea
commit 0ea66329b8
18 changed files with 163 additions and 154 deletions

View File

@@ -441,10 +441,10 @@ func (t *Terminal) printHeader() {
if line >= max {
continue
}
trimmed, colors, newState := extractColor(&lineStr, state)
trimmed, colors, newState := extractColor(lineStr, state)
state = newState
item := &Item{
text: trimmed,
text: []rune(trimmed),
index: 0,
colors: colors,
rank: Rank{0, 0, 0}}
@@ -537,7 +537,7 @@ func (t *Terminal) printHighlighted(item *Item, bold bool, col1 int, col2 int, c
}
// Overflow
text := []rune(*item.text)
text := item.text
offsets := item.colorOffsets(col2, bold, current)
maxWidth := C.MaxX() - 3 - t.marginInt[1] - t.marginInt[3]
fullWidth := displayWidth(text)