Commit 9270195d authored by Him188's avatar Him188

Fix CombinedMessage.toString, add caches.

parent fa932043
...@@ -55,14 +55,14 @@ internal constructor( ...@@ -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
} }
private var toStringCache: String? = null
@OptIn(MiraiExperimentalAPI::class) @OptIn(MiraiExperimentalAPI::class)
override fun toString(): String { override fun toString(): String = toStringCache ?: (left.toString() + tail.toString()).also { toStringCache = it }
return left.toString() + tail.toString()
}
override fun contentToString(): String { private var contentToStringCache: String? = null
return left.contentToString() + tail.contentToString() 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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment