Skip to content

Commit

Permalink
Avoid using zipWithIndex in executor (#2013)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou authored Nov 18, 2023
1 parent 9dd513e commit 3cb5e02
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/src/main/scala/caliban/execution/Executor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ object Executor {
)
)
case ListStep(steps) =>
reduceList(
steps.zipWithIndex.map { case (step, i) =>
reduceStep(step, currentField, arguments, Right(i) :: path)
},
Types.listOf(currentField.fieldType).fold(false)(_.isNullable)
)
var i = 0
val lb = List.newBuilder[ReducedStep[R]]
var remaining = steps
while (!remaining.isEmpty) {
lb += reduceStep(remaining.head, currentField, arguments, Right(i) :: path)
i += 1
remaining = remaining.tail
}
reduceList(lb.result(), Types.listOf(currentField.fieldType).fold(false)(_.isNullable))
case StreamStep(stream) =>
if (request.operationType == OperationType.Subscription) {
ReducedStep.StreamStep(
Expand Down

0 comments on commit 3cb5e02

Please sign in to comment.