Skip to content
Snippets Groups Projects
Commit f401c42f authored by Junegunn Choi's avatar Junegunn Choi
Browse files

Adjust initial coordinator delay

parent efec9acd
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,8 @@ import (
"time"
)
const COORDINATOR_DELAY time.Duration = 100 * time.Millisecond
const COORDINATOR_DELAY_MAX time.Duration = 100 * time.Millisecond
const COORDINATOR_DELAY_STEP time.Duration = 10 * time.Millisecond
func initProcs() {
runtime.GOMAXPROCS(runtime.NumCPU())
......@@ -151,8 +152,11 @@ func Run(options *Options) {
}
}
})
if ticks > 3 && delay && reading {
time.Sleep(COORDINATOR_DELAY)
if delay && reading {
dur := DurWithin(
time.Duration(ticks)*COORDINATOR_DELAY_STEP,
0, COORDINATOR_DELAY_MAX)
time.Sleep(dur)
}
}
}
package fzf
import "time"
func Max(first int, items ...int) int {
max := first
for _, item := range items {
......@@ -19,3 +21,14 @@ func Min(first int, items ...int) int {
}
return min
}
func DurWithin(
val time.Duration, min time.Duration, max time.Duration) time.Duration {
if val < min {
return min
}
if val > max {
return max
}
return val
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment