Replace deprecated usages of max/min with maxOrNull/minOrNull
This commit is contained in:
+2
-2
@@ -65,8 +65,8 @@ interface CompletionBenchmarkSink {
|
||||
pendingSessions -= completionSession
|
||||
perSessionResults[completionSession]?.onEnd(canceled)
|
||||
if (pendingSessions.isEmpty()) {
|
||||
val firstFlush = perSessionResults.values.filterNot { results -> results.canceled }.map { it.firstFlush }.min() ?: 0
|
||||
val full = perSessionResults.values.map { it.full }.max() ?: 0
|
||||
val firstFlush = perSessionResults.values.filterNot { results -> results.canceled }.minOfOrNull { it.firstFlush } ?: 0
|
||||
val full = perSessionResults.values.maxOfOrNull { it.full } ?: 0
|
||||
channel.offer(CompletionBenchmarkResults(firstFlush, full))
|
||||
reset()
|
||||
}
|
||||
|
||||
+2
-2
@@ -335,7 +335,7 @@ class LookupElementFactory(
|
||||
if (descriptor.overriddenDescriptors.isNotEmpty()) {
|
||||
// Optimization: when one of direct overridden fits, then nothing can fit better
|
||||
descriptor.overriddenDescriptors.mapNotNull { it.callableWeightBasedOnReceiver(receiverTypes, onReceiverTypeMismatch = null) }
|
||||
.minBy { it.enum }?.let { return it }
|
||||
.minByOrNull { it.enum }?.let { return it }
|
||||
|
||||
val overridden = descriptor.overriddenTreeUniqueAsSequence(useOriginal = false)
|
||||
return overridden.map { callableWeightBasic(it, receiverTypes)!! }.minBy { it.enum }!!
|
||||
@@ -397,7 +397,7 @@ class LookupElementFactory(
|
||||
val receiverIndex = bestReceiverType!!.receiverIndex
|
||||
|
||||
var receiverIndexToUse: Int? = receiverIndex
|
||||
val maxReceiverIndex = receiverTypes.map { it.receiverIndex }.max()!!
|
||||
val maxReceiverIndex = receiverTypes.maxOf { it.receiverIndex }
|
||||
if (maxReceiverIndex > 0) {
|
||||
val matchesAllReceivers = (0..maxReceiverIndex).all { it in matchingReceiverIndices }
|
||||
if (matchesAllReceivers) { // if descriptor is matching all receivers then use null as receiverIndex - otherwise e.g. all members of Any would have too high priority
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ object NameSimilarityWeigher : LookupElementWeigher("kotlin.nameSimilarity") {
|
||||
}
|
||||
|
||||
fun calcNameSimilarity(name: String, expectedInfos: Collection<ExpectedInfo>): Int =
|
||||
expectedInfos.mapNotNull { it.expectedName }.map { calcNameSimilarity(name, it) }.max() ?: 0
|
||||
expectedInfos.mapNotNull { it.expectedName }.maxOfOrNull { calcNameSimilarity(name, it) } ?: 0
|
||||
|
||||
private fun calcNameSimilarity(name: String, expectedName: String): Int {
|
||||
val words1 = NameUtil.nameToWordsLowerCase(name)
|
||||
|
||||
Reference in New Issue
Block a user