Actions
Bug #15797
closedUse `extends AnyVal` and remove HashCodeCaching for classes with one parameter
Status:
Released
Priority:
N/A
Assignee:
Category:
Performance and scalability
Target version:
Pull Request:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
Fix check:
To do
Regression:
Description
See https://docs.scala-lang.org/overviews/core/value-classes.html#summary_of_limitations
=> most of our IDs are suitable. May lead to far less pressure on GC.
Limitation are:
A value class … … must have only a primary constructor with exactly one public, val parameter whose type is not a user-defined value class. (From Scala 2.11.0, the parameter may be non-public.) … may not have specialized type parameters. … may not have nested or local classes, traits, or objects … may not define a equals or hashCode method. … must be a top-level class or a member of a statically accessible object … can only have defs as members. In particular, it cannot have lazy vals, vars, or vals as members. … cannot be extended by another class.
We also need to remove hashcodeCaching as the general feedback for it is that the JVM knows what it does on hashcode which is perhaps the most optimized code in it, and having a lazy val (or val) forced calculated at object creation has major perf impact.
Actions