=str #16349 fix map + map optimization
This commit is contained in:
parent
55980aded5
commit
67e2ba9263
2 changed files with 11 additions and 2 deletions
|
|
@ -39,5 +39,14 @@ class OptimizingActorBasedFlowMaterializerSpec extends AkkaSpec with ImplicitSen
|
||||||
|
|
||||||
Await.result(f, 5.seconds) should be(expected)
|
Await.result(f, 5.seconds) should be(expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"optimize map + map" in {
|
||||||
|
implicit val mat = FlowMaterializer().asInstanceOf[ActorBasedFlowMaterializer].copy(optimizations = Optimizations.all)
|
||||||
|
|
||||||
|
val fl = Source(1 to 100).map(_ + 2).map(_ * 2).fold(0)(_ + _)
|
||||||
|
val expected = (1 to 100).map(_ + 2).map(_ * 2).fold(0)(_ + _)
|
||||||
|
|
||||||
|
Await.result(fl, 5.seconds) should be(expected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ case class ActorBasedFlowMaterializer(override val settings: MaterializerSetting
|
||||||
case noMatch if !optimizations.simplification || (noMatch ne orig) ⇒ orig
|
case noMatch if !optimizations.simplification || (noMatch ne orig) ⇒ orig
|
||||||
|
|
||||||
// Two consecutive maps is equivalent to one pipelined map
|
// Two consecutive maps is equivalent to one pipelined map
|
||||||
case Ast.Map(second) :: Ast.Map(first) :: rest ⇒ Ast.Map(first compose second) :: rest
|
case Ast.Map(second) :: Ast.Map(first) :: rest ⇒ Ast.Map(first andThen second) :: rest
|
||||||
|
|
||||||
case noMatch ⇒ noMatch
|
case noMatch ⇒ noMatch
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue