Skip to content

Commit 79d9c11

Browse files
committed
optimization as respond to comments
1 parent 4310710 commit 79d9c11

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mllib/src/main/scala/org/apache/spark/mllib/util/MLUtils.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ object MLUtils {
8686
// check if indices are one-based and in ascending order
8787
var previous = -1
8888
var i = 0
89-
val indicesLength = indices.size
89+
val indicesLength = indices.length
9090
while (i < indicesLength) {
91-
require(indices(i) > previous, "indices should be one-based and in ascending order" )
92-
previous = indices(i)
91+
val current = indices(i)
92+
require(current > previous, "indices should be one-based and in ascending order" )
93+
previous = current
9394
i += 1
9495
}
9596

0 commit comments

Comments
 (0)