User story #1285
closed
Immutable case class hashcode caching
Added by François ARMAND over 13 years ago.
Updated over 9 years ago.
Category:
Architecture - Code maintenance
Description
The default hashCode implementation for case classes is a method. We can cache the result for mutable cache classes, which would give noticeable perf improvements during operations on HashSet/HashMap.
Ex: override lazy val hashCode(): Int = ScalaRunTime.this._hashCode(Foo.this);
=> Can also be generalized with something like "CachedHashCode":
@see: http://www.scala-lang.org/node/7930
The time estimation for this and a first iteration on non mutable classes is 1 hour, the remaining should be done afterwards.
- Estimated time changed from 2.00 h to 1.00 h
Trait implementation:
trait HashcodeCaching { self: Product => override lazy val hashCode: Int = { println("hashCode " + this); scala.runtime.ScalaRunTime._hashCode(this) } }
Thus, I leave only one estimated hour left so we can add it on needing case classes
- Category set to Architecture - Code maintenance
- Target version changed from 10 to 13
- Status changed from New to In progress
This issue is dedicated to the modification tracking about this. It will be updated to follow runs, and when done, just close it ;-)
- Tracker changed from Architecture to User story
- Target version changed from 13 to 14
- % Done changed from 0 to 30
- Target version changed from 14 to 15
- Target version changed from 15 to 16
- Target version changed from 16 to 19
- Target version changed from 19 to 21
- Target version changed from 21 to 23
- Target version changed from 23 to 18
- Target version changed from 18 to 2.4.0~alpha1
- Status changed from In progress to Pending technical review
- % Done changed from 30 to 100
- Assignee set to François ARMAND
- Status changed from Pending technical review to 10
This seems valid, i didn't find any case class left without the hashcode, but if any is found, we'll update this ticket
- Status changed from 10 to Released
- Subject changed from Cache des hashcode de case classes immutable to Immutable case class hashcode caching
- Description updated (diff)
Also available in: Atom
PDF