Skip to content

Commit 2c94c3b

Browse files
authored
Merge pull request #989 from retronym/faster/proto-read-1
Reduce overhead in analysis protobuf deserialization
2 parents a020abf + 91372c9 commit 2c94c3b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

internal/zinc-persist/src/main/scala/sbt/internal/inc/binary/converters/ProtobufReaders.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,9 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
271271
}
272272

273273
implicit class EfficientTraverse[T](seq: JList[T]) {
274-
def toZincArray[R: scala.reflect.ClassTag](f: T => R): Array[R] =
275-
seq.asScala.iterator.map(f).toArray
274+
def toZincArray[R <: AnyRef: scala.reflect.ClassTag](f: T => R): Array[R] = {
275+
seq.stream().map[R](x => f(x)).toArray[R](new Array[R](_))
276+
}
276277
}
277278

278279
implicit class OptionReader[T](option: Option[T]) {
@@ -695,9 +696,11 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
695696
val name = usedName.getName.intern()
696697
val useScopes = util.EnumSet.noneOf(classOf[UseScope])
697698
val len = usedName.getScopesCount
698-
val scopes = for {
699+
for {
699700
i <- 0 to len - 1
700-
} yield useScopes.add(fromUseScope(usedName.getScopes(i), usedName.getScopesValue(i)))
701+
} {
702+
useScopes.add(fromUseScope(usedName.getScopes(i), usedName.getScopesValue(i)))
703+
}
701704
UsedName.make(name, useScopes)
702705
}
703706

0 commit comments

Comments
 (0)