[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] = { def buildGroups(groups: Seq[Int]): Seq[Int] = {
val output = mutable.ArrayBuffer.empty[Int] val output = mutable.ArrayBuffer.empty[Int]
var count = 1 var count = 1
var i = 1 var lastGroup = groups.head
while (i < groups.length) { for (group <- groups.tail) {
if (groups(i) != groups(i - 1)) { if (group != lastGroup) {
lastGroup = group
output += count output += count
count = 1 count = 1
} else { } else {
count += 1 count += 1
} }
i += 1
} }
output += count output += count
output output