Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8-rc-1
-
Fix Version/s: 2.1.0-rc-2, 2.1.0
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
NOTE: @ToString moved to linked issue
For an immutable object, a hashcode value & toString value only need to be computed once and cached. Then the hashcode and toString methods can just return the cached values.
The @ToString and @EqualsAndHashCode ast transformation should have options to allow for caching. For example:
@ToString(cache=true)
@EqualsAndHashCode(cache=true)
Also, the @Immutable annotation should use the @ToString and @EqualsAndHashCode transformation with this caching capability enabled.
Issue Links
- relates to
-
GROOVY-5928
@ToString should allow caching of toString values
-
Activity
Guillaume Laforge
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.8-rc-3 [ 17228 ] | |
| Fix Version/s | 1.8-rc-2 [ 17176 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8-rc-4 [ 17245 ] | |
| Fix Version/s | 1.8-rc-3 [ 17228 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.7.11 [ 17244 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] | |
| Fix Version/s | 1.9-beta-1 [ 17153 ] | |
| Fix Version/s | 1.8-rc-4 [ 17245 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.2 [ 17495 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-2 [ 17494 ] | |
| Fix Version/s | 1.9-beta-1 [ 17153 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.3 [ 17657 ] | |
| Fix Version/s | 1.8.2 [ 17495 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-4 [ 17656 ] | |
| Fix Version/s | 1.9-beta-3 [ 17494 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.4 [ 17852 ] | |
| Fix Version/s | 1.8.3 [ 17657 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.9-beta-5 [ 17925 ] | |
| Fix Version/s | 1.9-beta-4 [ 17656 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.5 [ 18071 ] | |
| Fix Version/s | 1.8.4 [ 17852 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-beta-2 [ 18072 ] | |
| Fix Version/s | 2.0-beta-1 [ 17925 ] |
Paul King
made changes -
| Fix Version/s | 1.7.11 [ 17244 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.6 [ 18245 ] | |
| Fix Version/s | 1.8.5 [ 18071 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-beta-3 [ 18244 ] | |
| Fix Version/s | 2.0-beta-2 [ 18072 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.8.7 [ 18317 ] | |
| Fix Version/s | 1.8.6 [ 18245 ] |
blackdrag blackdrag
made changes -
| Assignee | Paul King [ paulk ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-rc-1 [ 18472 ] | |
| Fix Version/s | 2.0-beta-3 [ 18244 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-rc-2 [ 18550 ] | |
| Fix Version/s | 2.0-rc-1 [ 18472 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.0-rc-3 [ 18556 ] | |
| Fix Version/s | 2.0-rc-2 [ 18550 ] |
blackdrag blackdrag
made changes -
| Fix Version/s | 2.0-rc-4 [ 18600 ] | |
| Fix Version/s | 1.8.7 [ 18317 ] | |
| Fix Version/s | 2.0-rc-3 [ 18556 ] |
Cedric Champeau
made changes -
| Fix Version/s | 2.0.1 [ 18599 ] | |
| Fix Version/s | 2.0-rc-4 [ 18600 ] |
Cedric Champeau
made changes -
| Fix Version/s | 2.1.0 [ 18598 ] | |
| Fix Version/s | 2.0.1 [ 18599 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.1.0-rc-1 [ 19026 ] | |
| Fix Version/s | 2.1.0-beta-1 [ 18598 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 2.1.0-rc-2 [ 19054 ] | |
| Fix Version/s | 2.1.0-rc-1 [ 19026 ] |
Paul King
made changes -
| Link |
This issue relates to |
Paul King
made changes -
| Summary | @ToString, @EqualsAndHashCode should allow caching of toString & hashCode values | @EqualsAndHashCode should allow caching of hashCode values |
Paul King
made changes -
| Description |
For an immutable object, a hashcode value & toString value only need to be computed once and cached. Then the hashcode and toString methods can just return the cached values.
The @ToString and @EqualsAndHashCode ast transformation should have options to allow for caching. For example: @ToString(cache=true) @EqualsAndHashCode(cache=true) Also, the @Immutable annotation should use the @ToString and @EqualsAndHashCode transformation with this caching capability enabled. |
{quote}
NOTE: @ToString moved to linked issue {quote} For an immutable object, a hashcode value & toString value only need to be computed once and cached. Then the hashcode and toString methods can just return the cached values. The @ToString and @EqualsAndHashCode ast transformation should have options to allow for caching. For example: @ToString(cache=true) @EqualsAndHashCode(cache=true) Also, the @Immutable annotation should use the @ToString and @EqualsAndHashCode transformation with this caching capability enabled. |
Paul King
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.1.0 [ 19027 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
btw. See Effective Java 2nd ed. page 49 for details on caching of hashCodes. Josh Bloch talks about either calculating the hashcode on construction or lazily the first time it's requested.