Skip to content

Commit 85fee8f

Browse files
committed
chore: avoid create an empty array everytime.
1 parent 7184dad commit 85fee8f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

stream/src/main/scala/org/apache/pekko/stream/impl/PhasedFusingActorMaterializer.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,15 @@ private final case class SavedIslandData(
686686
*/
687687
@InternalApi private[pekko] object GraphStageTag extends IslandTag
688688

689+
/**
690+
* INTERNAL API
691+
*/
692+
@InternalApi
693+
private[pekko] object GraphStageIsland {
694+
// used as a type hint when creating the array of logics
695+
private final val logicArrayType = Array.empty[GraphStageLogic]
696+
}
697+
689698
/**
690699
* INTERNAL API
691700
*/
@@ -695,8 +704,6 @@ private final case class SavedIslandData(
695704
islandName: String,
696705
subflowFuser: OptionVal[GraphInterpreterShell => ActorRef])
697706
extends PhaseIsland[GraphStageLogic] {
698-
// TODO: remove these
699-
private val logicArrayType = Array.empty[GraphStageLogic]
700707
private[this] val logics = new util.ArrayList[GraphStageLogic](16)
701708

702709
private var connections = new Array[Connection](16)
@@ -815,7 +822,7 @@ private final case class SavedIslandData(
815822
}
816823

817824
shell.connections = finalConnections
818-
shell.logics = logics.toArray(logicArrayType)
825+
shell.logics = logics.toArray(GraphStageIsland.logicArrayType)
819826

820827
subflowFuser match {
821828
case OptionVal.Some(fuseIntoExistingInterpreter) =>

0 commit comments

Comments
 (0)