mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 11:37:40 +01:00
Performance improvement for the address serializer.
This commit is contained in:
@@ -40,16 +40,16 @@ actual data class Address actual constructor(
|
||||
dTag.bytesUsedInMemory()
|
||||
|
||||
actual override fun compareTo(other: Address): Int {
|
||||
val result = kind.compareTo(other.kind)
|
||||
return if (result == 0) {
|
||||
val result2 = pubKeyHex.compareTo(other.pubKeyHex)
|
||||
if (result2 == 0) {
|
||||
val kindComparison = kind.compareTo(other.kind)
|
||||
return if (kindComparison == 0) {
|
||||
val pubkeyComparison = pubKeyHex.compareTo(other.pubKeyHex)
|
||||
if (pubkeyComparison == 0) {
|
||||
dTag.compareTo(other.dTag)
|
||||
} else {
|
||||
result2
|
||||
pubkeyComparison
|
||||
}
|
||||
} else {
|
||||
result
|
||||
kindComparison
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,13 @@ class AddressSerializer {
|
||||
kind: Int,
|
||||
pubKeyHex: HexKey,
|
||||
dTag: String = "",
|
||||
) = "$kind:$pubKeyHex:$dTag"
|
||||
) = buildString {
|
||||
append(kind)
|
||||
append(":")
|
||||
append(pubKeyHex)
|
||||
append(":")
|
||||
append(dTag)
|
||||
}
|
||||
|
||||
fun parse(addressId: String): Address? {
|
||||
if (addressId.isBlank()) return null
|
||||
|
||||
Reference in New Issue
Block a user