Skip to content

Commit

Permalink
Merge pull request #1149 from sangria-graphql/micro_optimizations
Browse files Browse the repository at this point in the history
avoid some intermediate collections
  • Loading branch information
yanns authored Oct 23, 2024
2 parents 65a83b3 + ec61ffa commit 19bf882
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ private[execution] class FutureResolver[Ctx](

val resolved = future
.flatMap { vs =>
val errors = vs.flatMap(_.errors).toVector
val errors = vs.iterator.flatMap(_.errors).toVector
val successfulValues = vs.collect { case SeqFutRes(v, _, _) if v != null => v }
val dctx = vs.collect { case SeqFutRes(_, _, d) if d != null => d }

Expand Down Expand Up @@ -839,7 +839,7 @@ private[execution] class FutureResolver[Ctx](
else {
val allDeferred = complexRes.flatMap(_._2.deferred)
val finalValue = Future
.sequence(complexRes.map { case (astField, DeferredResult(_, future)) =>
.sequence(complexRes.iterator.map { case (astField, DeferredResult(_, future)) =>
future.map(astField -> _)
})
.map { results =>
Expand Down Expand Up @@ -1949,6 +1949,7 @@ private[execution] class FutureResolver[Ctx](
.map(
_.flatMap(collectProjectionsInternal(path, _, astFields, currLevel + 1))
.groupBy(_.name)
.iterator
.map(_._2.head)
.toVector)
.getOrElse(Vector.empty)
Expand Down

0 comments on commit 19bf882

Please sign in to comment.