aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2018-10-31 11:37:09 -0700
committerJack Koenig2018-10-31 15:22:26 -0700
commitc13c59e82955a82022bd5ca50600b58ead7bf9b1 (patch)
tree45c962975709edcb8f5f9be9f69964731bab023a /src
parent72b69311072fd48b7c0d5c0b0b318b4dbe5da154 (diff)
Speed up create_exps by replacing foldLeft + List appends with flatMap
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/Utils.scala7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala
index 2d1b0b74..53e8c157 100644
--- a/src/main/scala/firrtl/Utils.scala
+++ b/src/main/scala/firrtl/Utils.scala
@@ -256,10 +256,9 @@ object Utils extends LazyLogging {
case ex: ValidIf => create_exps(ex.value) map (e1 => ValidIf(ex.cond, e1, e1.tpe))
case ex => ex.tpe match {
case (_: GroundType) => Seq(ex)
- case (t: BundleType) => (t.fields foldLeft Seq[Expression]())((exps, f) =>
- exps ++ create_exps(WSubField(ex, f.name, f.tpe,times(gender(ex), f.flip))))
- case (t: VectorType) => (0 until t.size foldLeft Seq[Expression]())((exps, i) =>
- exps ++ create_exps(WSubIndex(ex, i, t.tpe,gender(ex))))
+ case t: BundleType =>
+ t.fields.flatMap(f => create_exps(WSubField(ex, f.name, f.tpe,times(gender(ex), f.flip))))
+ case t: VectorType => (0 until t.size).flatMap(i => create_exps(WSubIndex(ex, i, t.tpe,gender(ex))))
}
}