]> Cypherpunks.ru repositories - goredo.git/blobdiff - sources.go
Optimise memory storage of dependency information
[goredo.git] / sources.go
index 3f375a6fe58f666c01a5b190a5c82ee149bf20d5..95b8e4e5bcfb54d7611f4c5e0a29ea1b0dae40a1 100644 (file)
@@ -18,7 +18,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package main
 
 import (
-       "os"
+       "errors"
+       "io/fs"
        "path"
 )
 
@@ -36,26 +37,20 @@ func sourcesWalker(
                        continue
                }
                seenDeps[depPath] = struct{}{}
-               fdDep, err := os.Open(depPath)
+               depInfo, err := depRead(depPath)
                if err != nil {
                        if errors.Is(err, fs.ErrNotExist) {
                                continue
                        }
                        return ErrLine(err)
                }
-               depInfo, err := depRead(fdDep)
-               fdDep.Close()
-               if err != nil {
-                       return ErrLine(err)
-               }
-               for _, m := range depInfo.ifchanges {
-                       depTgt := m["Target"]
-                       depTgtAbsPath := mustAbs(path.Join(cwd, depTgt))
+               for _, dep := range depInfo.ifchanges {
+                       depTgtAbsPath := mustAbs(path.Join(cwd, dep.tgt))
                        if _, ok := seen[depTgtAbsPath]; ok {
                                continue
                        }
                        seen[depTgtAbsPath] = struct{}{}
-                       if isSrc(cwd, depTgt) {
+                       if isSrc(cwd, dep.tgt) {
                                srcs[cwdMustRel(depTgtAbsPath)] = struct{}{}
                        } else if depTgtAbsPath != tgtAbsPath {
                                if err := sourcesWalker(