diff options
| author | Jack Koenig | 2022-04-05 09:17:34 -0700 |
|---|---|---|
| committer | GitHub | 2022-04-05 09:17:34 -0700 |
| commit | aea60aa16e59e29a83d3724c2e3d189d99b2749f (patch) | |
| tree | f7e9ff89d488dcebe9efb25cfba58eb87c2ae04a | |
| parent | a2d48a5896335a567ddb21ed87fe38cd65d4764d (diff) | |
Use circuit name hashCode for circuit anno hashCode (#2504)
It is unclear if having more than one circuit annotation even works. If
it does, it is implausible that they would have the same circuit name
since that would correspond to a namespace collision.
| -rw-r--r-- | src/main/scala/firrtl/stage/FirrtlAnnotations.scala | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/stage/FirrtlAnnotations.scala b/src/main/scala/firrtl/stage/FirrtlAnnotations.scala index 515c8af9..7f4266fd 100644 --- a/src/main/scala/firrtl/stage/FirrtlAnnotations.scala +++ b/src/main/scala/firrtl/stage/FirrtlAnnotations.scala @@ -283,8 +283,12 @@ case class FirrtlCircuitAnnotation(circuit: Circuit) extends NoTargetAnnotation /* Caching the hashCode for a large circuit is necessary due to repeated queries, e.g., in * [[Compiler.propagateAnnotations]]. Not caching the hashCode will cause severe performance degredations for large * [[Annotations]]. + * @note Uses the hashCode of the name of the circuit. Creating a HashMap with different Circuits + * that nevertheless have the same name is extremely uncommon so collisions are not a concern. + * Include productPrefix so that this doesn't collide with other types that use a similar + * strategy and hash the same String. */ - override lazy val hashCode: Int = circuit.hashCode + override lazy val hashCode: Int = (this.productPrefix + circuit.main).hashCode } |
