mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 04:50:26 +08:00
Use asSequence.joinToString
This commit is contained in:
parent
85ea4563a4
commit
6b45f99160
mirai-core/src/commonMain/kotlin/net.mamoe.mirai
@ -52,7 +52,7 @@ class ContactList<C : Contact>(@MiraiInternalAPI val delegate: LockFreeLinkedLis
|
||||
return null
|
||||
}
|
||||
|
||||
override fun toString(): String = delegate.joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
||||
override fun toString(): String = delegate.asSequence().joinToString(separator = ", ", prefix = "ContactList(", postfix = ")")
|
||||
}
|
||||
|
||||
operator fun <C : Contact> LockFreeLinkedList<C>.get(id: Long): C {
|
||||
|
@ -15,18 +15,6 @@ import kotlinx.atomicfu.AtomicRef
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.atomicfu.loop
|
||||
|
||||
inline fun <E> LockFreeLinkedList<E>.joinToString(
|
||||
separator: CharSequence = ", ",
|
||||
prefix: CharSequence = "[",
|
||||
postfix: CharSequence = "]",
|
||||
transform: ((E) -> CharSequence) = { it.toString() }
|
||||
): String = prefix.toString() + buildString {
|
||||
this@joinToString.forEach {
|
||||
append(transform(it))
|
||||
append(separator)
|
||||
}
|
||||
}.dropLast(separator.length) + postfix
|
||||
|
||||
/**
|
||||
* Collect all the elements into a [MutableList] then cast it as a [List]
|
||||
*/
|
||||
@ -215,7 +203,7 @@ open class LockFreeLinkedList<E> {
|
||||
internal fun <E> LockFreeLinkedListNode<E>.compareAndSetNextNodeRef(expect: LockFreeLinkedListNode<E>, update: LockFreeLinkedListNode<E>) =
|
||||
this.nextNodeRef.compareAndSet(expect, update)
|
||||
|
||||
override fun toString(): String = joinToString()
|
||||
override fun toString(): String = asSequence().joinToString()
|
||||
|
||||
@Suppress("unused")
|
||||
internal fun getLinkStructure(): String = buildString {
|
||||
@ -754,7 +742,7 @@ internal open class Tail<E> : LockFreeLinkedListNode<E>(null, null) {
|
||||
|
||||
open class LockFreeLinkedListNode<E>(
|
||||
nextNode: LockFreeLinkedListNode<E>?,
|
||||
private var initialNodeValue: E?
|
||||
private val initialNodeValue: E?
|
||||
) {
|
||||
/*
|
||||
internal val id: Int = nextId()
|
||||
|
Loading…
Reference in New Issue
Block a user