[jvm-packages] avoid use of Seq.apply in buildGroups (#3413)

This commit is contained in:
Adam Johnston 2018-06-26 16:00:28 -07:00 committed by Nan Zhu
parent 5cd851ccef
commit 0988fb191f

View File

@ -311,15 +311,15 @@ private object Watches {
def buildGroups(groups: Seq[Int]): Seq[Int] = {
val output = mutable.ArrayBuffer.empty[Int]
var count = 1
var i = 1
while (i < groups.length) {
if (groups(i) != groups(i - 1)) {
var lastGroup = groups.head
for (group <- groups.tail) {
if (group != lastGroup) {
lastGroup = group
output += count
count = 1
} else {
count += 1
}
i += 1
}
output += count
output