Skip to content

Commit

Permalink
fix: small optimization in postgres name/path processors
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Oct 2, 2024
1 parent 2a97b9f commit c80b9c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ func (p *Postgres) processPaths(tx *gorm.DB, ipsw *model.Ipsw) error {
uniquePaths[fs.Path.Path] = struct{}{}
}

if len(uniquePaths) == 0 {
return nil
}

// Process paths in batches
paths := make([]string, 0, len(uniquePaths))
for path := range uniquePaths {
Expand Down Expand Up @@ -311,6 +315,10 @@ func (p *Postgres) processNames(tx *gorm.DB, ipsw *model.Ipsw) error {
}
}

if len(uniqueNames) == 0 {
return nil
}

// Process names in batches
names := make([]string, 0, len(uniqueNames))
for name := range uniqueNames {
Expand Down

0 comments on commit c80b9c3

Please sign in to comment.