GoLint
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 7833fa7 · Browse files · 3 files·+19 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+19 added−22 removed
- other:+19 added−22 removed
Provenance
- Commit
ae87f65- Tree
3cc3768- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
7833fa7
3 files changed+19 added−22 removed
modified:src/algo/algo.go+1 added
159 unmodified lines160 }161 return trimmedLen - len(pattern), trimmedLen162 }163 164+// EqualMatch performs equal-match165 func EqualMatch(caseSensitive bool, runes []rune, pattern []rune) (int, int) {166 if len(runes) != len(pattern) {167 return -1, -1168 }9 unmodified linesmodified:src/util/util.go+1 added-5 removed
18 unmodified lines19 }20 return max21 }22 23-// Max32 returns the smallest 32-bit integer23+// Min32 returns the smallest 32-bit integer24 func Min32(first int32, second int32) int32 {25 if first <= second {26 return first27 }41 unmodified lines69 }70 return val71 }72 73-func Between(val int, min int, max int) bool {74- return val >= min && val <= max75-}76-73 // IsTty returns true is stdin is a terminal74 func IsTty() bool {75 return int(C.isatty(C.int(os.Stdin.Fd()))) != 076 }26 unmodified linesmodified:src/item.go+17 added-17 removed
35 unmodified lines36 // Tiebreak criterion to use. Never changes once fzf is started.37 var rankTiebreak tiebreak38 39 // Rank calculates rank of the Item40-func (i *Item) Rank(cache bool) Rank {41- if cache && (i.rank.matchlen > 0 || i.rank.tiebreak > 0) {42- return i.rank40+func (item *Item) Rank(cache bool) Rank {41+ if cache && (item.rank.matchlen > 0 || item.rank.tiebreak > 0) {42+ return item.rank43 }44 matchlen := 045 prevEnd := 046 minBegin := math.MaxUint1647- for _, offset := range i.offsets {47+ for _, offset := range item.offsets {48 begin := int(offset[0])49 end := int(offset[1])50 if prevEnd > begin {51 begin = prevEnd11 unmodified lines63 var tiebreak uint1664 switch rankTiebreak {65 case byLength:66 // It is guaranteed that .transformed in not null in normal execution67- if i.transformed != nil {67+ if item.transformed != nil {68 lenSum := 069- for _, token := range i.transformed {69+ for _, token := range item.transformed {70 lenSum += len(token.text)71 }72 tiebreak = uint16(lenSum)73 } else {74- tiebreak = uint16(len(i.text))74+ tiebreak = uint16(len(item.text))75 }76 case byBegin:77- // We can't just look at i.offsets[0][0] because it can be an inverse term77+ // We can't just look at item.offsets[0][0] because it can be an inverse term78 tiebreak = uint16(minBegin)79 case byEnd:80 if prevEnd > 0 {81- tiebreak = uint16(1 + len(i.text) - prevEnd)81+ tiebreak = uint16(1 + len(item.text) - prevEnd)82 } else {83 // Empty offsets due to inverse terms.84 tiebreak = 185 }86 case byIndex:87 tiebreak = 188 }89- rank := Rank{uint16(matchlen), tiebreak, i.index}89+ rank := Rank{uint16(matchlen), tiebreak, item.index}90 if cache {91- i.rank = rank91+ item.rank = rank92 }93 return rank94 }95 96 // AsString returns the original string97-func (i *Item) AsString() string {98- return *i.StringPtr()97+func (item *Item) AsString() string {98+ return *item.StringPtr()99 }100 101 // StringPtr returns the pointer to the original string102-func (i *Item) StringPtr() *string {103- runes := i.text104- if i.origText != nil {105- runes = *i.origText102+func (item *Item) StringPtr() *string {103+ runes := item.text104+ if item.origText != nil {105+ runes = *item.origText106 }107 str := string(runes)108 return &str109 }154 unmodified lines