Skip to content

Commit ce6392e

Browse files
authored
Merge pull request #3392 from mpilquist/topic/from-iterator-perf
Fix performance of Stream.from(Blocking)Iterator when using large chunk sizes
2 parents 5d92cdb + aa566a3 commit ce6392e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/shared/src/main/scala/fs2/Stream.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3605,7 +3605,7 @@ object Stream extends StreamLowPriority {
36053605

36063606
def getNextChunk(i: Iterator[A]): F[Option[(Chunk[A], Iterator[A])]] =
36073607
F.suspend(hint) {
3608-
for (_ <- 1 to chunkSize if i.hasNext) yield i.next()
3608+
i.take(chunkSize).toVector
36093609
}.map { s =>
36103610
if (s.isEmpty) None else Some((Chunk.from(s), i))
36113611
}

0 commit comments

Comments
 (0)