File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
compiler/src/dotty/tools/dotc/util Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ class SparseIntArray:
28
28
29
29
def update (index : Int , value : Value ): Unit =
30
30
require(index >= 0 )
31
- while capacity <= index do grow()
31
+ while capacity <= index do
32
+ require(root.level < MaxLevels , " array index too large, maximum is 2^30 - 1" )
33
+ grow()
32
34
if ! root.update(index, value) then siz += 1
33
35
34
36
/** Remove element at `index` if it is present
@@ -76,6 +78,7 @@ object SparseIntArray:
76
78
77
79
private inline val NodeSizeLog = 5
78
80
private inline val NodeSize = 1 << NodeSizeLog
81
+ private inline val MaxLevels = 5 // max size is 2 ^ ((MaxLevels + 1) * NodeSizeLog) = 2 ^ 30
79
82
80
83
/** The exposed representation. Should be used just for nodeCount and
81
84
* low-level toString.
You can’t perform that action at this time.
0 commit comments