1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-03-26 07:20:09 +08:00

fuzzySearchMember: improve performance

This commit is contained in:
Him188 2022-03-01 14:17:57 +00:00
parent f7480fe38f
commit 68711538c8

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -57,8 +57,7 @@ internal fun Group.fuzzySearchMember(
*/
disambiguationRate: Double = 0.1,
): List<Pair<Member, Double>> {
val candidates = (this.members + botAsMember)
.asSequence()
val candidates = (this.members.asSequence() + botAsMember)
.associateWith { it.nameCard.fuzzyMatchWith(nameCardTarget) }
.filter { it.value >= minRate }
.toList()