You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/06/07 03:26:00 UTC
[jira] [Resolved] (GROOVY-8391) CLONE - hashCode() generated by @EqualsAndHashCode is inefficient for instances with null fields or properties (port/rework for 2_5_X/2_4_X)
[ https://issues.apache.org/jira/browse/GROOVY-8391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-8391.
-------------------------------
Resolution: Won't Fix
I will close as "Won't fix". If someone still wants this on an older Groovy version, please backport the fix and feel free to reopen.
> CLONE - hashCode() generated by @EqualsAndHashCode is inefficient for instances with null fields or properties (port/rework for 2_5_X/2_4_X)
> --------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-8391
> URL: https://issues.apache.org/jira/browse/GROOVY-8391
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.5.0-beta-2, 2.4.13
> Reporter: Marcin Erdmann
> Assignee: Paul King
> Priority: Major
> Labels: performance
>
> In a project I work on there is a relatively large hash map for which the key type has a {{@EqualsAndHashCode}} generated {{hashCode()}}. After introducing an additional property to the key type, for which the value is {{null}} on most instances, I noticed a massive degradation in efficiency of adds to the aforementioned map.
> After some digging around it turns out that the AST generated by that transform performs an identity check using {{is()}} between the property/field value and {{this}}. In cases where the property/field value is {{null}} this leads to a {{NullObject.is()}} call, for which, as far as I understand, no call site caching occurs.
> A PR with a jmh benchmark and a very simple fix to follow.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)