mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-24 07:38:36 +00:00
Code cleanup (#1640)
- Replaced time.Now().Sub() with time.Since() - Replaced unnecessary string/byte slice conversions - Removed obsolete return and value assignment in range loop
This commit is contained in:
parent
7322504ad0
commit
a1260feeed
@ -59,7 +59,7 @@ func (h *History) append(line string) error {
|
|||||||
|
|
||||||
lines := append(h.lines[:len(h.lines)-1], line)
|
lines := append(h.lines[:len(h.lines)-1], line)
|
||||||
if len(lines) > h.maxSize {
|
if len(lines) > h.maxSize {
|
||||||
lines = lines[len(lines)-h.maxSize : len(lines)]
|
lines = lines[len(lines)-h.maxSize:]
|
||||||
}
|
}
|
||||||
h.lines = append(lines, "")
|
h.lines = append(lines, "")
|
||||||
return ioutil.WriteFile(h.path, []byte(strings.Join(h.lines, "\n")), 0600)
|
return ioutil.WriteFile(h.path, []byte(strings.Join(h.lines, "\n")), 0600)
|
||||||
|
@ -207,13 +207,13 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
|
|||||||
return nil, wait()
|
return nil, wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
if time.Now().Sub(startedAt) > progressMinDuration {
|
if time.Since(startedAt) > progressMinDuration {
|
||||||
m.eventBox.Set(EvtSearchProgress, float32(count)/float32(numChunks))
|
m.eventBox.Set(EvtSearchProgress, float32(count)/float32(numChunks))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partialResults := make([][]Result, numSlices)
|
partialResults := make([][]Result, numSlices)
|
||||||
for _ = range slices {
|
for range slices {
|
||||||
partialResult := <-resultChan
|
partialResult := <-resultChan
|
||||||
partialResults[partialResult.index] = partialResult.matches
|
partialResults[partialResult.index] = partialResult.matches
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1532,7 @@ func (t *Terminal) Loop() {
|
|||||||
cmd.Wait()
|
cmd.Wait()
|
||||||
finishChan <- true
|
finishChan <- true
|
||||||
if out.Len() > 0 || !<-updateChan {
|
if out.Len() > 0 || !<-updateChan {
|
||||||
t.reqBox.Set(reqPreviewDisplay, string(out.Bytes()))
|
t.reqBox.Set(reqPreviewDisplay, out.String())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t.reqBox.Set(reqPreviewDisplay, "")
|
t.reqBox.Set(reqPreviewDisplay, "")
|
||||||
|
@ -238,7 +238,7 @@ func Transform(tokens []Token, withNth []Range) []Token {
|
|||||||
for _, part := range parts {
|
for _, part := range parts {
|
||||||
output.WriteString(part.ToString())
|
output.WriteString(part.ToString())
|
||||||
}
|
}
|
||||||
merged = util.ToChars([]byte(output.String()))
|
merged = util.ToChars(output.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
var prefixLength int32
|
var prefixLength int32
|
||||||
|
@ -547,7 +547,7 @@ func (r *LightRenderer) mouseSequence(sz *int) Event {
|
|||||||
r.prevDownTime = now
|
r.prevDownTime = now
|
||||||
} else {
|
} else {
|
||||||
if len(r.clickY) > 1 && r.clickY[0] == r.clickY[1] &&
|
if len(r.clickY) > 1 && r.clickY[0] == r.clickY[1] &&
|
||||||
time.Now().Sub(r.prevDownTime) < doubleClickDuration {
|
time.Since(r.prevDownTime) < doubleClickDuration {
|
||||||
double = true
|
double = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,6 @@ func (chars *Chars) CopyRunes(dest []rune) {
|
|||||||
for idx, b := range chars.slice[:len(dest)] {
|
for idx, b := range chars.slice[:len(dest)] {
|
||||||
dest[idx] = rune(b)
|
dest[idx] = rune(b)
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (chars *Chars) Prepend(prefix string) {
|
func (chars *Chars) Prepend(prefix string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user