This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new cc7fa75731 =str Use OptionVal in Recover instead of Option.
cc7fa75731 is described below

commit cc7fa75731f14e1a430ab156db417bfa0204c0ba
Author: He-Pin <[email protected]>
AuthorDate: Sat Sep 2 22:06:23 2023 +0800

    =str Use OptionVal in Recover instead of Option.
---
 .../org/apache/pekko/stream/impl/fusing/Ops.scala  | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git 
a/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala 
b/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
index 05f864c2e3..3d9ff981e2 100644
--- a/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/impl/fusing/Ops.scala
@@ -287,23 +287,17 @@ private[stream] object Collect {
 
   override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
     new GraphStageLogic(shape) with InHandler with OutHandler {
-
       import Collect.NotApplied
 
-      var recovered: Option[T] = None
+      var recovered: OptionVal[T] = OptionVal.none
 
-      override def onPush(): Unit = {
-        push(out, grab(in))
-      }
+      override def onPush(): Unit = push(out, grab(in))
 
-      override def onPull(): Unit = {
-        recovered match {
-          case Some(elem) =>
-            push(out, elem)
-            completeStage()
-          case None =>
-            pull(in)
-        }
+      override def onPull(): Unit = recovered match {
+        case OptionVal.Some(elem) =>
+          push(out, elem)
+          completeStage()
+        case _ => pull(in)
       }
 
       override def onUpstreamFailure(ex: Throwable): Unit =
@@ -314,7 +308,7 @@ private[stream] object Collect {
                 push(out, result)
                 completeStage()
               } else {
-                recovered = Some(result)
+                recovered = OptionVal.Some(result)
               }
             }
             case _ => throw new RuntimeException() // won't happen, compiler 
exhaustiveness check pleaser


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

Reply via email to