From dcef05b53b08ac395d678b508e9523b1d1005136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E=E9=B8=A3?= Date: Sat, 21 Dec 2024 16:51:42 +0800 Subject: [PATCH] chore: avoid create an empty array everytime. --- .../stream/impl/PhasedFusingActorMaterializer.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/stream/src/main/scala/org/apache/pekko/stream/impl/PhasedFusingActorMaterializer.scala b/stream/src/main/scala/org/apache/pekko/stream/impl/PhasedFusingActorMaterializer.scala index 2e70ce0d00..c130aed607 100644 --- a/stream/src/main/scala/org/apache/pekko/stream/impl/PhasedFusingActorMaterializer.scala +++ b/stream/src/main/scala/org/apache/pekko/stream/impl/PhasedFusingActorMaterializer.scala @@ -686,6 +686,15 @@ private final case class SavedIslandData( */ @InternalApi private[pekko] object GraphStageTag extends IslandTag +/** + * INTERNAL API + */ +@InternalApi +private[pekko] object GraphStageIsland { + // used as a type hint when creating the array of logics + private final val emptyLogicArray = Array.empty[GraphStageLogic] +} + /** * INTERNAL API */ @@ -695,8 +704,6 @@ private final case class SavedIslandData( islandName: String, subflowFuser: OptionVal[GraphInterpreterShell => ActorRef]) extends PhaseIsland[GraphStageLogic] { - // TODO: remove these - private val logicArrayType = Array.empty[GraphStageLogic] private[this] val logics = new util.ArrayList[GraphStageLogic](16) private var connections = new Array[Connection](16) @@ -815,7 +822,7 @@ private final case class SavedIslandData( } shell.connections = finalConnections - shell.logics = logics.toArray(logicArrayType) + shell.logics = logics.toArray(GraphStageIsland.emptyLogicArray) subflowFuser match { case OptionVal.Some(fuseIntoExistingInterpreter) =>