=str #16349 fix map + map optimization

This commit is contained in:
Martynas Mickevičius 2014-11-20 17:01:49 +02:00
parent 55980aded5
commit 67e2ba9263
2 changed files with 11 additions and 2 deletions

View file

@ -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)
}
} }
} }

View file

@ -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
} }