pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/pkglint/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Wed Mar 18 08:42:49 UTC 2020

Modified Files:
        pkgsrc/pkgtools/pkglint/files: pkgsrc.go pkgsrc_test.go

Log Message:
pkgtools/pkglint: increase performance


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 pkgsrc/pkgtools/pkglint/files/pkgsrc.go
cvs rdiff -u -r1.45 -r1.46 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint/files/pkgsrc.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.52 pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.53
--- pkgsrc/pkgtools/pkglint/files/pkgsrc.go:1.52        Wed Mar 18 08:24:49 2020
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc.go     Wed Mar 18 08:42:48 2020
@@ -885,9 +885,10 @@ func (src *Pkgsrc) ListVersions(category
        }
 
        var names []string
+       dir := src.File(category)
        for _, fileInfo := range src.ReadDir(category) {
                name := fileInfo.Name()
-               if matches(name, re) {
+               if matches(name, re) && !isEmptyDir(dir.JoinNoClean(NewRelPathString(name))) {
                        names = append(names, name)
                }
        }
@@ -1075,8 +1076,10 @@ func (src *Pkgsrc) IsBuildDef(varname st
 }
 
 // ReadDir lists the files and subdirectories from the given directory
-// (relative to the pkgsrc root), filtering out any ignored files (CVS/*)
-// and empty directories.
+// (relative to the pkgsrc root).
+//
+// The result may contain empty directories that are left over from CVS.
+// For performance reasons, the caller needs to filter these out; see isEmptyDir.
 func (src *Pkgsrc) ReadDir(dirName PkgsrcPath) []os.FileInfo {
        dir := src.File(dirName)
        files, err := dir.ReadDir()
@@ -1087,8 +1090,7 @@ func (src *Pkgsrc) ReadDir(dirName Pkgsr
        var relevantFiles []os.FileInfo
        for _, dirent := range files {
                name := dirent.Name()
-               // TODO: defer isEmptyDir, for performance reasons; run ktrace or strace to see why.
-               if !dirent.IsDir() || !isIgnoredFilename(name) && !isEmptyDir(dir.JoinNoClean(NewRelPathString(name))) {
+               if !dirent.IsDir() || !isIgnoredFilename(name) {
                        relevantFiles = append(relevantFiles, dirent)
                }
        }

Index: pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go
diff -u pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.45 pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.46
--- pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go:1.45   Wed Mar 18 08:24:49 2020
+++ pkgsrc/pkgtools/pkglint/files/pkgsrc_test.go        Wed Mar 18 08:42:49 2020
@@ -1272,7 +1272,7 @@ func (s *Suite) Test_Pkgsrc_ReadDir(c *c
                names = append(names, info.Name())
        }
 
-       t.CheckDeepEquals(names, []string{"aaa-subdir", "file", "subdir"})
+       t.CheckDeepEquals(names, []string{"aaa-subdir", "empty", "file", "subdir"})
 }
 
 func (s *Suite) Test_Pkgsrc_Relpath(c *check.C) {



Home | Main Index | Thread Index | Old Index