Skip to content

Commit b146501

Browse files
committed
avoiding multiple list iterations via mapNotNull
1 parent be67836 commit b146501

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

vector/src/main/java/im/vector/app/features/notifications/ProcessedEvent.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ data class ProcessedEvent<T>(
2727
}
2828
}
2929

30-
fun <T> List<ProcessedEvent<T>>.onlyKeptEvents() = filter { it.type == ProcessedEvent.Type.KEEP }.map { it.event }
30+
fun <T> List<ProcessedEvent<T>>.onlyKeptEvents() = mapNotNull { processedEvent ->
31+
processedEvent.event.takeIf { processedEvent.type == ProcessedEvent.Type.KEEP }
32+
}

0 commit comments

Comments
 (0)