This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new a3a8cf32d3 try to remove unnecessary map calls (#2292)
a3a8cf32d3 is described below

commit a3a8cf32d3b821d263008bb49e5c94526d4e9c5a
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Oct 2 18:19:05 2025 +0100

    try to remove unnecessary map calls (#2292)
---
 .../apache/pekko/actor/typed/scaladsl/package.scala  | 20 ++++++++++----------
 .../apache/pekko/actor/setup/ActorSystemSetup.scala  |  4 ++--
 .../main/scala/org/apache/pekko/event/Logging.scala  |  4 ++--
 .../persistence/query/typed/EventEnvelope.scala      |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git 
a/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/package.scala
 
b/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/package.scala
index 1737d63486..a79f82bea2 100644
--- 
a/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/package.scala
+++ 
b/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/package.scala
@@ -84,7 +84,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.trace(format, arr.asInstanceOf[Array[Object]]: _*) // this seems 
to always be the case
       else
-        log.trace(format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.trace(format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -105,7 +105,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.trace(marker, format, arr.asInstanceOf[Array[Object]]: _*) // this 
seems to always be the case
       else
-        log.trace(marker, format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.trace(marker, format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -155,7 +155,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.debug(format, arr.asInstanceOf[Array[Object]]: _*) // this seems 
to always be the case
       else
-        log.debug(format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.debug(format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -176,7 +176,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.debug(marker, format, arr.asInstanceOf[Array[Object]]: _*) // this 
seems to always be the case
       else
-        log.debug(marker, format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.debug(marker, format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -226,7 +226,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.info(format, arr.asInstanceOf[Array[Object]]: _*) // this seems to 
always be the case
       else
-        log.info(format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.info(format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -247,7 +247,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.info(marker, format, arr.asInstanceOf[Array[Object]]: _*) // this 
seems to always be the case
       else
-        log.info(marker, format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.info(marker, format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -297,7 +297,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.warn(format, arr.asInstanceOf[Array[Object]]: _*) // this seems to 
always be the case
       else
-        log.warn(format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.warn(format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -318,7 +318,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.warn(marker, format, arr.asInstanceOf[Array[Object]]: _*) // this 
seems to always be the case
       else
-        log.warn(marker, format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.warn(marker, format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -368,7 +368,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.error(format, arr.asInstanceOf[Array[Object]]: _*) // this seems 
to always be the case
       else
-        log.error(format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.error(format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
     /**
@@ -389,7 +389,7 @@ package object scaladsl {
       if (arr.isInstanceOf[Array[Object]])
         log.error(marker, format, arr.asInstanceOf[Array[Object]]: _*) // this 
seems to always be the case
       else
-        log.error(marker, format, arr.map(_.asInstanceOf[AnyRef]): _*)
+        log.error(marker, format, arr.asInstanceOf[Array[AnyRef]]: _*)
     }
 
   }
diff --git 
a/actor/src/main/scala/org/apache/pekko/actor/setup/ActorSystemSetup.scala 
b/actor/src/main/scala/org/apache/pekko/actor/setup/ActorSystemSetup.scala
index 152688220a..1394483f3f 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/setup/ActorSystemSetup.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/setup/ActorSystemSetup.scala
@@ -67,7 +67,7 @@ final class ActorSystemSetup private[pekko] (@InternalApi 
private[pekko] val set
    * Java API: Extract a concrete [[pekko.actor.setup.Setup]] of type `T` if 
it is defined in the settings.
    */
   def get[T <: Setup](clazz: Class[T]): Optional[T] = {
-    setups.get(clazz).map(_.asInstanceOf[T]).toJava
+    setups.get(clazz).toJava.asInstanceOf[Optional[T]]
   }
 
   /**
@@ -75,7 +75,7 @@ final class ActorSystemSetup private[pekko] (@InternalApi 
private[pekko] val set
    */
   def get[T <: Setup: ClassTag]: Option[T] = {
     val clazz = implicitly[ClassTag[T]].runtimeClass
-    setups.get(clazz).map(_.asInstanceOf[T])
+    setups.get(clazz).asInstanceOf[Option[T]]
   }
 
   /**
diff --git a/actor/src/main/scala/org/apache/pekko/event/Logging.scala 
b/actor/src/main/scala/org/apache/pekko/event/Logging.scala
index fdaf05c93f..6bb38e560f 100644
--- a/actor/src/main/scala/org/apache/pekko/event/Logging.scala
+++ b/actor/src/main/scala/org/apache/pekko/event/Logging.scala
@@ -1531,7 +1531,7 @@ trait LoggingAdapter {
    */
   private def format1(t: String, arg: Any): String = arg match {
     case a: Array[_] if !a.getClass.getComponentType.isPrimitive => 
formatImpl(t, a.toSeq)
-    case a: Array[_]                                             => 
formatImpl(t, a.map(_.asInstanceOf[AnyRef]).toSeq)
+    case a: Array[_]                                             => 
formatImpl(t, a.toSeq.asInstanceOf[Seq[AnyRef]])
     case x                                                       => format(t, 
x)
   }
 
@@ -2003,7 +2003,7 @@ class MarkerLoggingAdapter(
   // Copy of LoggingAdapter.format1 due to binary compatibility restrictions
   private def format1(t: String, arg: Any): String = arg match {
     case a: Array[_] if !a.getClass.getComponentType.isPrimitive => format(t, 
a.toIndexedSeq)
-    case a: Array[_]                                             => format(t, 
a.map(_.asInstanceOf[AnyRef]).toIndexedSeq)
+    case a: Array[_]                                             => format(t, 
a.toIndexedSeq.asInstanceOf[IndexedSeq[AnyRef]])
     case x                                                       => format(t, 
x)
   }
 }
diff --git 
a/persistence-query/src/main/scala/org/apache/pekko/persistence/query/typed/EventEnvelope.scala
 
b/persistence-query/src/main/scala/org/apache/pekko/persistence/query/typed/EventEnvelope.scala
index ab45eb2b21..a87ccbf198 100644
--- 
a/persistence-query/src/main/scala/org/apache/pekko/persistence/query/typed/EventEnvelope.scala
+++ 
b/persistence-query/src/main/scala/org/apache/pekko/persistence/query/typed/EventEnvelope.scala
@@ -102,7 +102,7 @@ final class EventEnvelope[Event](
    */
   def getEventMetaData(): Optional[AnyRef] = {
     import scala.jdk.OptionConverters._
-    eventMetadata.map(_.asInstanceOf[AnyRef]).toJava
+    eventMetadata.toJava.asInstanceOf[Optional[AnyRef]]
   }
 
   override def hashCode(): Int = {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to