diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala index 27ee565474..d64e6b5bb4 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Source.scala @@ -289,20 +289,8 @@ object Source { * } * }}} */ - def unfoldInf[S, E](s: S)(f: S ⇒ (S, E)): Source[E, Unit] = { - Source.fromGraph(GraphDSL.create() { implicit b ⇒ - import GraphDSL.Implicits._ - - val uzip = b.add(UnzipWith(f)) - val cnct = b.add(Concat[S]()) - val init = Source.single(s) - - init ~> cnct ~> uzip.in - cnct <~ Flow[S].buffer(2, OverflowStrategy.backpressure) <~ uzip.out0 - - SourceShape(uzip.out1) - }).withAttributes(DefaultAttributes.unfoldInf) - } + def unfoldInf[S, E](s: S)(f: S ⇒ (S, E)): Source[E, Unit] = + unfold(s)(s ⇒ Some(f(s))).withAttributes(DefaultAttributes.unfoldInf) /** * A `Source` with no elements, i.e. an empty stream that is completed immediately for every connected `Sink`.