use forEach: no intermediate list created.

This commit is contained in:
davotoula
2026-03-06 22:38:05 +01:00
parent 03171f97a5
commit f8187bad14
5 changed files with 9 additions and 9 deletions
@@ -41,7 +41,7 @@ class ListWithUniqueSetCache<T, U>(
}
fun distinct(): Set<U> {
var currentSet = cacheSet.get()
val currentSet = cacheSet.get()
// Check if the cached set is based on the current list
if (currentSet != null) {
@@ -40,7 +40,7 @@ fun potentialRelaysToFindAddress(note: AddressableNote): Set<NormalizedRelayUrl>
LocalCache.getAnyChannel(note)?.relays()?.let { set.addAll(it) }
note.replyTo?.map { parentNote ->
note.replyTo?.forEach { parentNote ->
set.addAll(parentNote.relays)
LocalCache.getAnyChannel(parentNote)?.relays()?.let { set.addAll(it) }
@@ -48,7 +48,7 @@ fun potentialRelaysToFindAddress(note: AddressableNote): Set<NormalizedRelayUrl>
parentNote.author?.inboxRelays()?.let { set.addAll(it) }
}
note.replies.map { childNote ->
note.replies.forEach { childNote ->
set.addAll(childNote.relays)
LocalCache.getAnyChannel(childNote)?.relays()?.let { set.addAll(it) }
@@ -63,7 +63,7 @@ fun potentialRelaysToFindAddress(note: AddressableNote): Set<NormalizedRelayUrl>
}
}
note.boosts.map { childNote ->
note.boosts.forEach { childNote ->
set.addAll(childNote.relays)
childNote.author?.outboxRelays()?.let { set.addAll(it) }
}
@@ -36,7 +36,7 @@ fun potentialRelaysToFindEvent(note: Note): Set<NormalizedRelayUrl> {
LocalCache.getAnyChannel(note)?.relays()?.let { set.addAll(it) }
note.replyTo?.map { parentNote ->
note.replyTo?.forEach { parentNote ->
set.addAll(parentNote.relays)
LocalCache.getAnyChannel(parentNote)?.relays()?.let { set.addAll(it) }
@@ -44,7 +44,7 @@ fun potentialRelaysToFindEvent(note: Note): Set<NormalizedRelayUrl> {
parentNote.author?.inboxRelays()?.let { set.addAll(it) }
}
note.replies.map { childNote ->
note.replies.forEach { childNote ->
set.addAll(childNote.relays)
LocalCache.getAnyChannel(childNote)?.relays()?.let { set.addAll(it) }
@@ -59,7 +59,7 @@ fun potentialRelaysToFindEvent(note: Note): Set<NormalizedRelayUrl> {
}
}
note.boosts.map { childNote ->
note.boosts.forEach { childNote ->
set.addAll(childNote.relays)
childNote.author?.outboxRelays()?.let { set.addAll(it) }
}
@@ -68,7 +68,7 @@ class UserCardsSubAssembler(
val trustedAccounts: Map<NormalizedRelayUrl, Set<HexKey>> =
mapOfSet {
accounts.forEach { account ->
account.homeRelays.flow.value.map {
account.homeRelays.flow.value.forEach {
add(it, account.userProfile().pubkeyHex)
}
}
@@ -167,7 +167,7 @@ fun ObserveAllStatusesToAvoidSwitchigAllTheTime(
statuses: ImmutableList<AddressableNote>,
accountViewModel: AccountViewModel,
) {
statuses.map {
statuses.forEach {
EventFinderFilterAssemblerSubscription(it, accountViewModel)
}
}