Skip to content

Commit

Permalink
chore: avoid create an empty array everytime.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Dec 22, 2024
1 parent 8bb6e22 commit dcef05b
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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)
Expand Down Expand Up @@ -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) =>
Expand Down

0 comments on commit dcef05b

Please sign in to comment.