mirror of https://github.com/apache/kafka.git
MINOR: Optimize the entriesWithoutErrorsPerPartition when errorResults is empty (#20410)
If `errorResults` is empty, there’s no need to create a new `entriesPerPartition` map. Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
49ee1fb4f9
commit
a9b2a6d9b6
|
@ -788,7 +788,11 @@ class ReplicaManager(val config: KafkaConfig,
|
||||||
hasCustomErrorMessage = customException.isDefined
|
hasCustomErrorMessage = customException.isDefined
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val entriesWithoutErrorsPerPartition = entriesPerPartition.filter { case (key, _) => !errorResults.contains(key) }
|
// In non-transaction paths, errorResults is typically empty, so we can
|
||||||
|
// directly use entriesPerPartition instead of creating a new filtered collection
|
||||||
|
val entriesWithoutErrorsPerPartition =
|
||||||
|
if (errorResults.nonEmpty) entriesPerPartition.filter { case (key, _) => !errorResults.contains(key) }
|
||||||
|
else entriesPerPartition
|
||||||
|
|
||||||
val preAppendPartitionResponses = buildProducePartitionStatus(errorResults).map { case (k, status) => k -> status.responseStatus }
|
val preAppendPartitionResponses = buildProducePartitionStatus(errorResults).map { case (k, status) => k -> status.responseStatus }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue