Skip to content

Commit

Permalink
Merge pull request #989 from retronym/faster/proto-read-1
Browse files Browse the repository at this point in the history
Reduce overhead in analysis protobuf deserialization
  • Loading branch information
eed3si9n authored Jun 22, 2021
2 parents a020abf + 91372c9 commit 2c94c3b
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,9 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
}

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

implicit class OptionReader[T](option: Option[T]) {
Expand Down Expand Up @@ -695,9 +696,11 @@ final class ProtobufReaders(mapper: ReadMapper, currentVersion: Schema.Version)
val name = usedName.getName.intern()
val useScopes = util.EnumSet.noneOf(classOf[UseScope])
val len = usedName.getScopesCount
val scopes = for {
for {
i <- 0 to len - 1
} yield useScopes.add(fromUseScope(usedName.getScopes(i), usedName.getScopesValue(i)))
} {
useScopes.add(fromUseScope(usedName.getScopes(i), usedName.getScopesValue(i)))
}
UsedName.make(name, useScopes)
}

Expand Down

0 comments on commit 2c94c3b

Please sign in to comment.