perf: remove redundant sort (#2510)
This commit is contained in:
1 parent
d90dce7e4d
commit
66bc58b4bf
2 files changed
+4
-5
No files matched your search
@@ -391,8 +391,7 @@ func (app *app) loop() {
|
|||||||
oldCurrPath = curr.path
|
oldCurrPath = curr.path
|
||||||
}
|
}
|
||||||
|
|
||||||
prev, ok := app.nav.dirCache[d.path]
|
if prev, ok := app.nav.dirCache[d.path]; ok {
|
||||||
if ok {
|
|
||||||
d.ind = prev.ind
|
d.ind = prev.ind
|
||||||
d.pos = prev.pos
|
d.pos = prev.pos
|
||||||
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
||||||
@@ -400,6 +399,8 @@ func (app *app) loop() {
|
|||||||
d.filter = prev.filter
|
d.filter = prev.filter
|
||||||
d.sort()
|
d.sort()
|
||||||
d.sel(prev.name(), app.nav.height)
|
d.sel(prev.name(), app.nav.height)
|
||||||
|
} else {
|
||||||
|
d.sort()
|
||||||
}
|
}
|
||||||
app.nav.dirCache[d.path] = d
|
app.nav.dirCache[d.path] = d
|
||||||
|
|
||||||
|
|||||||
@@ -144,9 +144,7 @@ func (watch *watch) processUpdate(update watchUpdate) {
|
|||||||
switch update.kind {
|
switch update.kind {
|
||||||
case "dir":
|
case "dir":
|
||||||
if _, err := os.Lstat(update.path); err == nil {
|
if _, err := os.Lstat(update.path); err == nil {
|
||||||
dir := newDir(update.path)
|
watch.dirChan <- newDir(update.path)
|
||||||
dir.sort()
|
|
||||||
watch.dirChan <- dir
|
|
||||||
}
|
}
|
||||||
case "file":
|
case "file":
|
||||||
if _, err := os.Lstat(update.path); err == nil {
|
if _, err := os.Lstat(update.path); err == nil {
|
||||||
|
|||||||
Reference in new issue
Block a user