hachikuji commented on a change in pull request #9299:
URL: https://github.com/apache/kafka/pull/9299#discussion_r490586608
##########
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:
The name reads a tad awkwardly. I wonder if `foreachKeyValue` would be
too verbose. Or maybe `foreachMapEntry`?
----------------------------------------------------------------
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:
[email protected]