use forEach: no intermediate list created.
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ class ListWithUniqueSetCache<T, U>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun distinct(): Set<U> {
|
fun distinct(): Set<U> {
|
||||||
var currentSet = cacheSet.get()
|
val currentSet = cacheSet.get()
|
||||||
|
|
||||||
// Check if the cached set is based on the current list
|
// Check if the cached set is based on the current list
|
||||||
if (currentSet != null) {
|
if (currentSet != null) {
|
||||||
|
|||||||
+3
-3
@@ -40,7 +40,7 @@ fun potentialRelaysToFindAddress(note: AddressableNote): Set<NormalizedRelayUrl>
|
|||||||
|
|
||||||
LocalCache.getAnyChannel(note)?.relays()?.let { set.addAll(it) }
|
LocalCache.getAnyChannel(note)?.relays()?.let { set.addAll(it) }
|
||||||
|
|
||||||
note.replyTo?.map { parentNote ->
|
note.replyTo?.forEach { parentNote ->
|
||||||
set.addAll(parentNote.relays)
|
set.addAll(parentNote.relays)
|
||||||
|
|
||||||
LocalCache.getAnyChannel(parentNote)?.relays()?.let { set.addAll(it) }
|
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) }
|
parentNote.author?.inboxRelays()?.let { set.addAll(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
note.replies.map { childNote ->
|
note.replies.forEach { childNote ->
|
||||||
set.addAll(childNote.relays)
|
set.addAll(childNote.relays)
|
||||||
|
|
||||||
LocalCache.getAnyChannel(childNote)?.relays()?.let { set.addAll(it) }
|
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)
|
set.addAll(childNote.relays)
|
||||||
childNote.author?.outboxRelays()?.let { set.addAll(it) }
|
childNote.author?.outboxRelays()?.let { set.addAll(it) }
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -36,7 +36,7 @@ fun potentialRelaysToFindEvent(note: Note): Set<NormalizedRelayUrl> {
|
|||||||
|
|
||||||
LocalCache.getAnyChannel(note)?.relays()?.let { set.addAll(it) }
|
LocalCache.getAnyChannel(note)?.relays()?.let { set.addAll(it) }
|
||||||
|
|
||||||
note.replyTo?.map { parentNote ->
|
note.replyTo?.forEach { parentNote ->
|
||||||
set.addAll(parentNote.relays)
|
set.addAll(parentNote.relays)
|
||||||
|
|
||||||
LocalCache.getAnyChannel(parentNote)?.relays()?.let { set.addAll(it) }
|
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) }
|
parentNote.author?.inboxRelays()?.let { set.addAll(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
note.replies.map { childNote ->
|
note.replies.forEach { childNote ->
|
||||||
set.addAll(childNote.relays)
|
set.addAll(childNote.relays)
|
||||||
|
|
||||||
LocalCache.getAnyChannel(childNote)?.relays()?.let { set.addAll(it) }
|
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)
|
set.addAll(childNote.relays)
|
||||||
childNote.author?.outboxRelays()?.let { set.addAll(it) }
|
childNote.author?.outboxRelays()?.let { set.addAll(it) }
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ class UserCardsSubAssembler(
|
|||||||
val trustedAccounts: Map<NormalizedRelayUrl, Set<HexKey>> =
|
val trustedAccounts: Map<NormalizedRelayUrl, Set<HexKey>> =
|
||||||
mapOfSet {
|
mapOfSet {
|
||||||
accounts.forEach { account ->
|
accounts.forEach { account ->
|
||||||
account.homeRelays.flow.value.map {
|
account.homeRelays.flow.value.forEach {
|
||||||
add(it, account.userProfile().pubkeyHex)
|
add(it, account.userProfile().pubkeyHex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -167,7 +167,7 @@ fun ObserveAllStatusesToAvoidSwitchigAllTheTime(
|
|||||||
statuses: ImmutableList<AddressableNote>,
|
statuses: ImmutableList<AddressableNote>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
) {
|
) {
|
||||||
statuses.map {
|
statuses.forEach {
|
||||||
EventFinderFilterAssemblerSubscription(it, accountViewModel)
|
EventFinderFilterAssemblerSubscription(it, accountViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user