ijuma commented on a change in pull request #9299:
URL: https://github.com/apache/kafka/pull/9299#discussion_r491149647



##########
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:
       Thanks for the feedback. I agree that the name could be improved. I was 
hoping for something concise and descriptive. `foreachPair` is not bad, but 
you'd expect to get a pair (tuple) and this is to avoid that. How about 
`forKeyValue`?




----------------------------------------------------------------
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


Reply via email to