From 901e800012c788280108e5dc5822d303809464c0 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:20:50 +1100 Subject: [PATCH] fix: use a set for the from/to serialized lists (#1370) --- .../main/java/org/session/libsession/utilities/Address.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/utilities/Address.kt b/libsession/src/main/java/org/session/libsession/utilities/Address.kt index c8cd11d4b6..e265e28e7d 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/Address.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/Address.kt @@ -8,7 +8,6 @@ import androidx.annotation.VisibleForTesting import org.session.libsignal.utilities.IdPrefix import org.session.libsignal.utilities.Util import org.session.libsignal.utilities.guava.Optional -import java.util.Collections import java.util.LinkedList import java.util.concurrent.atomic.AtomicReference import java.util.regex.Matcher @@ -168,8 +167,9 @@ class Address private constructor(address: String) : Parcelable, Comparable { val escapedAddresses = DelimiterUtil.split(serialized, delimiter) + val set = escapedAddresses.toSet().sorted() val addresses: MutableList
= LinkedList() - for (escapedAddress in escapedAddresses) { + for (escapedAddress in set) { addresses.add(fromSerialized(DelimiterUtil.unescape(escapedAddress, delimiter))) } return addresses @@ -177,9 +177,9 @@ class Address private constructor(address: String) : Parcelable, Comparable, delimiter: Char): String { - Collections.sort(addresses) + val set = addresses.toSet().sorted() val escapedAddresses: MutableList = LinkedList() - for (address in addresses) { + for (address in set) { escapedAddresses.add(DelimiterUtil.escape(address.serialize(), delimiter)) } return Util.join(escapedAddresses, delimiter.toString() + "")