Skip to content
This repository was archived by the owner on Dec 28, 2022. It is now read-only.

Fix slow library loading with a lot of inclusions or exclusions #535

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import io.reactivex.functions.Function3
import io.reactivex.schedulers.Schedulers
import java.util.ArrayList
import java.util.Arrays
import java.util.Locale
import javax.inject.Inject
import javax.inject.Singleton

Expand Down Expand Up @@ -194,15 +195,21 @@ open class SongsRepository @Inject constructor(

// Filter out excluded paths
if (!exclItems.isEmpty()) {
val exclSongPaths = exclItems
.map { it.path.toLowerCase(Locale.ROOT) }
.toHashSet()
result = songs
.filterNot { song -> exclItems.any { exclItem -> StringUtils.containsIgnoreCase(song.path, exclItem.path) } }
.filterNot { it.path.toLowerCase(Locale.ROOT) in exclSongPaths }
.toList()
}

// Filter out non-included paths
if (!inclItems.isEmpty()) {
val inclSongPaths = inclItems
.map { it.path.toLowerCase(Locale.ROOT) }
.toHashSet()
result = result
.filter { song -> inclItems.any { inclItem -> StringUtils.containsIgnoreCase(song.path, inclItem.path) } }
.filter { it.path.toLowerCase(Locale.ROOT) in inclSongPaths }
.toList()
}

Expand Down