Skip to content

Commit 7ed6637

Browse files
committed
use Once
1 parent 2a88d5c commit 7ed6637

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

executor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ type (
6464
UserWorkingDir string
6565
EnableVersionCheck bool
6666

67-
fuzzyModel *fuzzy.Model
67+
fuzzyModel *fuzzy.Model
68+
fuzzyModelOnce sync.Once
6869

6970
concurrencySemaphore chan struct{}
7071
taskCallCount map[string]*int32

task.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,7 @@ func (e *Executor) GetTask(call *Call) (*ast.Task, error) {
451451
if len(aliasedTasks) == 0 {
452452
didYouMean := ""
453453
if !e.DisableFuzzy {
454-
// Lazy initialization of fuzzy model
455-
if e.fuzzyModel == nil {
456-
e.setupFuzzyModel()
457-
}
454+
e.fuzzyModelOnce.Do(e.setupFuzzyModel)
458455
if e.fuzzyModel != nil {
459456
didYouMean = e.fuzzyModel.SpellCheck(call.Task)
460457
}

0 commit comments

Comments
 (0)