File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
library/src/scala/collection/immutable Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,14 @@ private[immutable] abstract class ChampBaseIterator[T <: Node[T]] {
105
105
protected var currentValueNode : T = _
106
106
107
107
private [this ] var currentStackLevel : Int = - 1
108
- private [this ] val nodeCursorsAndLengths : Array [Int ] = new Array [Int ](MaxDepth * 2 )
109
- private [this ] val nodes : Array [T ] = new Array [Node [T ]](MaxDepth ).asInstanceOf [Array [T ]]
108
+ private [this ] var nodeCursorsAndLengths : Array [Int ] = _
109
+ private [this ] var nodes : Array [T ] = _
110
+ private def initNodes (): Unit = {
111
+ if (nodeCursorsAndLengths eq null ) {
112
+ nodeCursorsAndLengths = new Array [Int ](MaxDepth * 2 )
113
+ nodes = new Array [Node [T ]](MaxDepth ).asInstanceOf [Array [T ]]
114
+ }
115
+ }
110
116
111
117
def this (rootNode : T ) = {
112
118
this ()
@@ -121,6 +127,7 @@ private[immutable] abstract class ChampBaseIterator[T <: Node[T]] {
121
127
}
122
128
123
129
private final def pushNode (node : T ): Unit = {
130
+ initNodes()
124
131
currentStackLevel = currentStackLevel + 1
125
132
126
133
val cursorIndex = currentStackLevel * 2
You can’t perform that action at this time.
0 commit comments