Skip to content

Commit 15b7e3c

Browse files
authored
refactor: VeryFastCompile for Task list (#2053)
1 parent 7c93ea8 commit 15b7e3c

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ func (e *Executor) GetTaskList(filters ...FilterFunc) ([]*ast.Task, error) {
498498
// Compile the list of tasks
499499
for i := range tasks {
500500
g.Go(func() error {
501-
compiledTask, err := e.FastCompiledTask(&Call{Task: tasks[i].Task})
501+
compiledTask, err := e.CompiledTaskForTaskList(&Call{Task: tasks[i].Task})
502502
if err != nil {
503503
return err
504504
}

variables.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,51 @@ func (e *Executor) FastCompiledTask(call *Call) (*ast.Task, error) {
2929
return e.compiledTask(call, false)
3030
}
3131

32+
func (e *Executor) CompiledTaskForTaskList(call *Call) (*ast.Task, error) {
33+
origTask, err := e.GetTask(call)
34+
if err != nil {
35+
return nil, err
36+
}
37+
38+
vars, err := e.Compiler.FastGetVariables(origTask, call)
39+
if err != nil {
40+
return nil, err
41+
}
42+
43+
cache := &templater.Cache{Vars: vars}
44+
45+
return &ast.Task{
46+
Task: origTask.Task,
47+
Label: templater.Replace(origTask.Label, cache),
48+
Desc: templater.Replace(origTask.Desc, cache),
49+
Prompt: templater.Replace(origTask.Prompt, cache),
50+
Summary: templater.Replace(origTask.Summary, cache),
51+
Aliases: origTask.Aliases,
52+
Sources: origTask.Sources,
53+
Generates: origTask.Generates,
54+
Dir: origTask.Dir,
55+
Set: origTask.Set,
56+
Shopt: origTask.Shopt,
57+
Vars: vars,
58+
Env: nil,
59+
Dotenv: origTask.Dotenv,
60+
Silent: origTask.Silent,
61+
Interactive: origTask.Interactive,
62+
Internal: origTask.Internal,
63+
Method: origTask.Method,
64+
Prefix: origTask.Prefix,
65+
IgnoreError: origTask.IgnoreError,
66+
Run: origTask.Run,
67+
IncludeVars: origTask.IncludeVars,
68+
IncludedTaskfileVars: origTask.IncludedTaskfileVars,
69+
Platforms: origTask.Platforms,
70+
Location: origTask.Location,
71+
Requires: origTask.Requires,
72+
Watch: origTask.Watch,
73+
Namespace: origTask.Namespace,
74+
}, nil
75+
}
76+
3277
func (e *Executor) compiledTask(call *Call, evaluateShVars bool) (*ast.Task, error) {
3378
origTask, err := e.GetTask(call)
3479
if err != nil {

0 commit comments

Comments
 (0)