I'm creating a few rather big objects and many of them are duplicates. So I thought about using Guava's Interner
for them and always work with the interned object only (i.e., each object gets interned just after creation).
It occurred to me that equals
of those objects is rather slow (and gets used a lot) and that I actually never need it, as a.equals(b)
is equivalent to a == b
after interning. Unfortunately, the Interner
itself uses equals
so I have to override it for the single use.
I wonder if there's a simple way to have my equals and eat it?
Disclaimer: I know about the root of all evil and I'm not sure if optimization on this place is worth the effort. However, I'm interested if the above problem has a nice solution.