pjfanning commented on code in PR #2560:
URL: https://github.com/apache/pekko/pull/2560#discussion_r2616366994


##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -567,8 +561,12 @@ object Source {
    * Emits a single value when the given `Future` is successfully completed 
and then completes the stream.
    * The stream fails if the `Future` is completed with a failure.
    */
-  def future[T](futureElement: Future[T]): Source[T, NotUsed] =
-    fromGraph(new FutureSource[T](futureElement))
+  def future[T](futureElement: Future[T]): Source[T, NotUsed] = 
futureElement.value match {
+    case Some(scala.util.Success(null)) => empty[T]

Review Comment:
   The Scala compiler might produce an optimized if or switch but I'd prefer if 
the code here explicitly checked for future element.value == None first as this 
is the most likely result. Checking this last could lead to unnecessary extra 
checks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to