Skip to content
Myr

Code cleanup (#1640)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- Replaced time.Now().Sub() with time.Since() - Replaced unnecessary string/byte slice conversions - Removed obsolete return and value assignment in range loop

authored by Christian Muehlhaeuser · committed by Junegunn Choi · parent 7322504 · Browse files · 6 files+6 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+6 added−7 removed

  • other:+6 added−7 removed

6 files+6 added−7 removed

modified:src/tui/light.go+1 added-1 removed
545 unmodified lines
546 }547 r.prevDownTime = now548 } else {549 if len(r.clickY) > 1 && r.clickY[0] == r.clickY[1] &&550 time.Now().Sub(r.prevDownTime) < doubleClickDuration {550 time.Since(r.prevDownTime) < doubleClickDuration {551 double = true552 }553 }554
390 unmodified lines
modified:src/util/chars.go-1 removed
167 unmodified lines
168 }169 for idx, b := range chars.slice[:len(dest)] {170 dest[idx] = rune(b)171 }172 return172}173174func (chars *Chars) Prepend(prefix string) {175 if runes := chars.optionalRunes(); runes != nil {
6 unmodified lines
modified:src/history.go+1 added-1 removed
57 unmodified lines
58 }5960 lines := append(h.lines[:len(h.lines)-1], line)61 if len(lines) > h.maxSize {62 lines = lines[len(lines)-h.maxSize : len(lines)]62 lines = lines[len(lines)-h.maxSize:]63 }64 h.lines = append(lines, "")65 return ioutil.WriteFile(h.path, []byte(strings.Join(h.lines, "\n")), 0600)66}
30 unmodified lines
modified:src/matcher.go+2 added-2 removed
205 unmodified lines
206 if m.reqBox.Peek(reqReset) {207 return nil, wait()208 }209210 if time.Now().Sub(startedAt) > progressMinDuration {210 if time.Since(startedAt) > progressMinDuration {211 m.eventBox.Set(EvtSearchProgress, float32(count)/float32(numChunks))212 }213 }214215 partialResults := make([][]Result, numSlices)216 for _ = range slices {216 for range slices {217 partialResult := <-resultChan218 partialResults[partialResult.index] = partialResult.matches219 }220 return NewMerger(pattern, partialResults, m.sort, m.tac), false
14 unmodified lines
modified:src/terminal.go+1 added-1 removed
1530 unmodified lines
1531 }()1532 cmd.Wait()1533 finishChan <- true1534 if out.Len() > 0 || !<-updateChan {1535 t.reqBox.Set(reqPreviewDisplay, string(out.Bytes()))1535 t.reqBox.Set(reqPreviewDisplay, out.String())1536 }1537 } else {1538 t.reqBox.Set(reqPreviewDisplay, "")1539 }
538 unmodified lines
modified:src/tokenizer.go+1 added-1 removed
236 unmodified lines
237 var output bytes.Buffer238 for _, part := range parts {239 output.WriteString(part.ToString())240 }241 merged = util.ToChars([]byte(output.String()))241 merged = util.ToChars(output.Bytes())242 }243244 var prefixLength int32245 if minIdx < numTokens {
8 unmodified lines