From aea60aa16e59e29a83d3724c2e3d189d99b2749f Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 5 Apr 2022 09:17:34 -0700 Subject: 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.--- src/main/scala/firrtl/stage/FirrtlAnnotations.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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 } -- cgit v1.2.3