diff options
| author | Jack Koenig | 2018-05-24 15:18:58 -0700 |
|---|---|---|
| committer | GitHub | 2018-05-24 15:18:58 -0700 |
| commit | e03e3f730250673ffa48c000caa369ed582467a2 (patch) | |
| tree | 9a3e7a1c93e10ce77c1b84ce65150b5c9e83deb4 /chiselFrontend/src/main | |
| parent | d64ee7dd5d536f043cbbae4f1d2a4a01c4ba91e8 (diff) | |
Use Vec.apply instead of new Vec in VecInit.apply (#825)
The Vec constructor invokes the gen argument for each element in the
Vec. Since VecInit invokes cloneSupertype which touches every element of
the input Seq, this was an n^2 operation. Vec.apply accepts its
arguments by value so cloneSupertype is only called once. It then calls
cloneType on that once for each element in the Vec, which is constant
time reducing the overall complexity of VecInit to just n.
Diffstat (limited to 'chiselFrontend/src/main')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala index 18ab8dc2..35d2c0f6 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala @@ -277,7 +277,7 @@ object VecInit { require(!elts.isEmpty) elts.foreach(requireIsHardware(_, "vec element")) - val vec = Wire(new Vec(cloneSupertype(elts, "Vec"), elts.length)) + val vec = Wire(Vec(elts.length, cloneSupertype(elts, "Vec"))) // TODO: try to remove the logic for this mess elts.head.direction match { |
