Skip to content

Commit 8462995

Browse files
committed
refactor: TodoCategory 선호도 중복 확인 로직 개선
1 parent 8c0f76d commit 8462995

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Application/DevLogData/Sources/Mapper/TodoCategoryMapping.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,18 @@ private func mergedTodoCategoryPreferences(
7676
_ preferences: [TodoCategoryPreference]
7777
) -> [TodoCategoryPreference] {
7878
var mergedPreferences = preferences
79-
80-
for systemTodoCategory in SystemTodoCategory.allCases {
81-
let containsSystemTodoCategory = preferences.contains { preference in
82-
guard case .system(let currentSystemTodoCategory) = preference.category else {
83-
return false
79+
let existingSystemTodoCategories = Set<SystemTodoCategory>(
80+
preferences.compactMap { preference in
81+
guard case .system(let systemTodoCategory) = preference.category else {
82+
return nil
8483
}
8584

86-
return currentSystemTodoCategory == systemTodoCategory
85+
return systemTodoCategory
8786
}
87+
)
8888

89-
if containsSystemTodoCategory { continue }
89+
for systemTodoCategory in SystemTodoCategory.allCases {
90+
if existingSystemTodoCategories.contains(systemTodoCategory) { continue }
9091

9192
mergedPreferences.append(
9293
TodoCategoryPreference(

0 commit comments

Comments
 (0)