mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-12 14:00:12 +08:00
Fix CombinedMessage.toString, add caches.
This commit is contained in:
parent
fa93204339
commit
9270195d31
@ -55,14 +55,14 @@ internal constructor(
|
|||||||
return other is CombinedMessage && other.left == this.left && other.tail == this.tail
|
return other is CombinedMessage && other.left == this.left && other.tail == this.tail
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(MiraiExperimentalAPI::class)
|
private var toStringCache: String? = null
|
||||||
override fun toString(): String {
|
|
||||||
return left.toString() + tail.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun contentToString(): String {
|
@OptIn(MiraiExperimentalAPI::class)
|
||||||
return left.contentToString() + tail.contentToString()
|
override fun toString(): String = toStringCache ?: (left.toString() + tail.toString()).also { toStringCache = it }
|
||||||
}
|
|
||||||
|
private var contentToStringCache: String? = null
|
||||||
|
override fun contentToString(): String =
|
||||||
|
contentToStringCache ?: (left.contentToString() + tail.contentToString()).also { contentToStringCache = it }
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
var result = left.hashCode()
|
var result = left.hashCode()
|
||||||
|
Loading…
Reference in New Issue
Block a user