Skip to content

Commit a75945a

Browse files
committed
Slight improvement of removeBuildFromSketchFiles
1 parent 9b7b9d2 commit a75945a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

commands/service_compile.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
169169
if buildPathArg := req.GetBuildPath(); buildPathArg != "" {
170170
buildPath = paths.New(req.GetBuildPath()).Canonical()
171171
if in, _ := buildPath.IsInsideDir(sk.FullPath); in && buildPath.IsDir() {
172-
if sk.AdditionalFiles, err = removeBuildFromSketchFiles(sk.AdditionalFiles, buildPath); err != nil {
172+
if sk.AdditionalFiles, err = removeBuildPathFromSketchFiles(sk.AdditionalFiles, buildPath); err != nil {
173173
return err
174174
}
175175
}
@@ -462,15 +462,15 @@ func maybePurgeBuildCache(compilationsBeforePurge uint, cacheTTL time.Duration)
462462
buildcache.New(paths.TempDir().Join("arduino", "sketches")).Purge(cacheTTL)
463463
}
464464

465-
// removeBuildFromSketchFiles removes the files contained in the build directory from
465+
// removeBuildPathFromSketchFiles removes the files contained in the build directory from
466466
// the list of the sketch files
467-
func removeBuildFromSketchFiles(files paths.PathList, build *paths.Path) (paths.PathList, error) {
467+
func removeBuildPathFromSketchFiles(files paths.PathList, build *paths.Path) (paths.PathList, error) {
468468
var res paths.PathList
469469
ignored := false
470470
for _, file := range files {
471471
if isInside, _ := file.IsInsideDir(build); !isInside {
472-
res = append(res, file)
473-
} else if !ignored {
472+
res.Add(file)
473+
} else {
474474
ignored = true
475475
}
476476
}

0 commit comments

Comments
 (0)