mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 23:46:50 +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()
|
dTag.bytesUsedInMemory()
|
||||||
|
|
||||||
actual override fun compareTo(other: Address): Int {
|
actual override fun compareTo(other: Address): Int {
|
||||||
val result = kind.compareTo(other.kind)
|
val kindComparison = kind.compareTo(other.kind)
|
||||||
return if (result == 0) {
|
return if (kindComparison == 0) {
|
||||||
val result2 = pubKeyHex.compareTo(other.pubKeyHex)
|
val pubkeyComparison = pubKeyHex.compareTo(other.pubKeyHex)
|
||||||
if (result2 == 0) {
|
if (pubkeyComparison == 0) {
|
||||||
dTag.compareTo(other.dTag)
|
dTag.compareTo(other.dTag)
|
||||||
} else {
|
} else {
|
||||||
result2
|
pubkeyComparison
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result
|
kindComparison
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,13 @@ class AddressSerializer {
|
|||||||
kind: Int,
|
kind: Int,
|
||||||
pubKeyHex: HexKey,
|
pubKeyHex: HexKey,
|
||||||
dTag: String = "",
|
dTag: String = "",
|
||||||
) = "$kind:$pubKeyHex:$dTag"
|
) = buildString {
|
||||||
|
append(kind)
|
||||||
|
append(":")
|
||||||
|
append(pubKeyHex)
|
||||||
|
append(":")
|
||||||
|
append(dTag)
|
||||||
|
}
|
||||||
|
|
||||||
fun parse(addressId: String): Address? {
|
fun parse(addressId: String): Address? {
|
||||||
if (addressId.isBlank()) return null
|
if (addressId.isBlank()) return null
|
||||||
|
|||||||
Reference in New Issue
Block a user