chore: avoid create an empty array everytime.

This commit is contained in:
虎鸣 2024-12-21 16:51:42 +08:00 committed by He-Pin(kerr)
parent bfa37ffcf4
commit 2b916125f0

View file

@ -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) =>