From f7b1e23eadebdc956b68dbd6f5e8eedb04bb6241 Mon Sep 17 00:00:00 2001 From: Henry Cook Date: Thu, 10 Jul 2014 16:59:48 -0700 Subject: [PATCH] functional style on MuxBundle --- uncore/src/main/scala/coherence.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/uncore/src/main/scala/coherence.scala b/uncore/src/main/scala/coherence.scala index 5fa0b7a6..1a3c4573 100644 --- a/uncore/src/main/scala/coherence.scala +++ b/uncore/src/main/scala/coherence.scala @@ -5,11 +5,7 @@ import Chisel._ object MuxBundle { def apply[T <: Data] (default: T, mapping: Seq[(Bool, T)]): T = { - var res = default; - for ((t, v) <- mapping.reverse){ - res = Mux(t, v, res); - } - res + mapping.reverse.foldLeft(default)((b, a) => Mux(a._1, a._2, b)) } }