Micro-optimizations

- Make structs smaller
- Introduce Result struct and use it to represent matched items instead of
  reusing Item struct for that purpose
- Avoid unnecessary memory allocation
- Avoid growing slice from the initial capacity
- Code cleanup
This commit is contained in:
Junegunn Choi
2016-08-19 02:39:32 +09:00
parent f7f01d109e
commit 37dc273148
19 changed files with 236 additions and 570 deletions

View File

@@ -95,6 +95,7 @@ type criterion int
const (
byMatchLen criterion = iota
byBonus
byLength
byBegin
byEnd
@@ -178,7 +179,7 @@ func defaultOptions() *Options {
Delimiter: Delimiter{},
Sort: 1000,
Tac: false,
Criteria: []criterion{byMatchLen, byLength},
Criteria: []criterion{byMatchLen, byBonus, byLength},
Multi: false,
Ansi: false,
Mouse: true,
@@ -406,7 +407,7 @@ func parseKeyChords(str string, message string) map[int]string {
}
func parseTiebreak(str string) []criterion {
criteria := []criterion{byMatchLen}
criteria := []criterion{byMatchLen, byBonus}
hasIndex := false
hasLength := false
hasBegin := false