ijuma commented on a change in pull request #9299: URL: https://github.com/apache/kafka/pull/9299#discussion_r492361262
########## File path: core/src/main/scala/kafka/utils/Implicits.scala ########## @@ -46,4 +47,21 @@ object Implicits { } + /** + * Exposes `foreachKv` which maps to `foreachEntry` in Scala 2.13 and `foreach` in Scala 2.12 + * (with the help of scala.collection.compat). `foreachEntry` avoids the tuple allocation and + * is more efficient. + * + * This was not named `foreachEntry` to avoid `unused import` warnings in Scala 2.13 (the implicit + * would not be triggered in Scala 2.13 since `Map.foreachEntry` would have precedence). + */ + @nowarn("cat=unused-imports") + implicit class MapExtensionMethods[K, V](private val self: scala.collection.Map[K, V]) extends AnyVal { + import scala.collection.compat._ + def foreachKv[U](f: (K, V) => U): Unit = { Review comment: Checked with @hachikuji and he's fine with this change. ---------------------------------------------------------------- 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