ijuma commented on a change in pull request #9206: URL: https://github.com/apache/kafka/pull/9206#discussion_r492823279
########## File path: core/src/main/scala/kafka/log/LogValidator.scala ########## @@ -279,14 +280,15 @@ private[log] object LogValidator extends Logging { val firstBatch = getFirstBatchAndMaybeValidateNoMoreBatches(records, NoCompressionCodec) - for (batch <- records.batches.asScala) { + records.batches.forEach { batch => validateBatch(topicPartition, firstBatch, batch, origin, magic, brokerTopicStats) var maxBatchTimestamp = RecordBatch.NO_TIMESTAMP var offsetOfMaxBatchTimestamp = -1L val recordErrors = new ArrayBuffer[ApiRecordError](0) - for ((record, batchIndex) <- batch.asScala.view.zipWithIndex) { + var batchIndex = 0 Review comment: Worth adding a comment here that this is a hot path and we want to avoid any unnecessary allocations. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org