mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Avoiding to recall Ipv4Int on every loop
This commit is contained in:
parent
6701cb1dc1
commit
31669efc51
@ -97,7 +97,8 @@ class IP2Country private constructor(private val context: Context) {
|
||||
|
||||
val comps = ipv4ToCountry.asSequence()
|
||||
|
||||
val bestMatchCountry = comps.lastOrNull { it.key <= Ipv4Int(ip) }?.let { (_, code) ->
|
||||
val ipInt = Ipv4Int(ip)
|
||||
val bestMatchCountry = comps.lastOrNull { it.key <= ipInt }?.let { (_, code) ->
|
||||
if (code != null) {
|
||||
countryToNames[code]
|
||||
} else {
|
||||
|
@ -2,10 +2,7 @@ package org.thoughtcrime.securesms.util;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class ListUtil {
|
||||
@ -21,16 +18,4 @@ public final class ListUtil {
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> List<T> concat(Collection<T>... items) {
|
||||
//noinspection Convert2MethodRef
|
||||
final List<T> concat = new ArrayList<>(Stream.of(items).map(Collection::size).reduce(0, (lhs, rhs) -> lhs+rhs));
|
||||
|
||||
for (Collection<T> list : items) {
|
||||
concat.addAll(list);
|
||||
}
|
||||
|
||||
return concat;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user