Replace map[string]bool with map[string]struct{}

This commit is contained in:
Deluan
2020-06-12 14:09:40 -04:00
committed by Deluan Quintão
parent e73b71aaf7
commit 653b5ea9d3
+4 -4
View File
@@ -35,8 +35,8 @@ func NewTagScanner(rootFolder string, ds model.DataStore) *TagScanner {
} }
type ( type (
ArtistMap map[string]bool ArtistMap map[string]struct{}
AlbumMap map[string]bool AlbumMap map[string]struct{}
) )
const ( const (
@@ -235,7 +235,7 @@ func (s *TagScanner) processChangedDir(ctx context.Context, dir string, updatedA
} }
func (s *TagScanner) updateAlbum(ctx context.Context, albumId string, updatedAlbums AlbumMap) error { func (s *TagScanner) updateAlbum(ctx context.Context, albumId string, updatedAlbums AlbumMap) error {
updatedAlbums[albumId] = true updatedAlbums[albumId] = struct{}{}
if len(updatedAlbums) >= batchSize { if len(updatedAlbums) >= batchSize {
err := s.flushAlbums(ctx, updatedAlbums) err := s.flushAlbums(ctx, updatedAlbums)
if err != nil { if err != nil {
@@ -246,7 +246,7 @@ func (s *TagScanner) updateAlbum(ctx context.Context, albumId string, updatedAlb
} }
func (s *TagScanner) updateArtist(ctx context.Context, artistId string, updatedArtists ArtistMap) error { func (s *TagScanner) updateArtist(ctx context.Context, artistId string, updatedArtists ArtistMap) error {
updatedArtists[artistId] = true updatedArtists[artistId] = struct{}{}
if len(updatedArtists) >= batchSize { if len(updatedArtists) >= batchSize {
err := s.flushArtists(ctx, updatedArtists) err := s.flushArtists(ctx, updatedArtists)
if err != nil { if err != nil {