mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-11 21:30:11 +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
|
||||
}
|
||||
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
override fun toString(): String {
|
||||
return left.toString() + tail.toString()
|
||||
}
|
||||
private var toStringCache: String? = null
|
||||
|
||||
override fun contentToString(): String {
|
||||
return left.contentToString() + tail.contentToString()
|
||||
}
|
||||
@OptIn(MiraiExperimentalAPI::class)
|
||||
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 {
|
||||
var result = left.hashCode()
|
||||
|
Loading…
Reference in New Issue
Block a user