perf: cleanup nested loop

This commit is contained in:
Antoine Aflalo
2024-08-26 23:17:21 -04:00
parent 135db7a1f8
commit d7e3bc6399

View File

@@ -25,7 +25,9 @@ func LoadChapter(filePath string) (*packer.Chapter, error) {
} }
for _, f := range r.File { for _, f := range r.File {
if !f.FileInfo().IsDir() { if f.FileInfo().IsDir() {
continue
}
// Open the file inside the zip // Open the file inside the zip
rc, err := f.Open() rc, err := f.Open()
if err != nil { if err != nil {
@@ -81,7 +83,7 @@ func LoadChapter(filePath string) (*packer.Chapter, error) {
chapter.Pages = append(chapter.Pages, page) chapter.Pages = append(chapter.Pages, page)
} }
rc.Close() rc.Close()
}
} }
return chapter, nil return chapter, nil