[MDSAL-400] Optimize DatataObject.hashCode() Created: 18/Nov/18  Updated: 22/Nov/18  Resolved: 22/Nov/18

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: None
Fix Version/s: 3.0.2

Type: Improvement Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

We currently generate the following code for single-entry classes:

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + Objects.hashCode(_lockName);
        return result;
    }

This is wasteful, as we could simply delegate to _lockName(), which could be caching hashCode (as String does), thus arithmetics from hashCode().

We should end up with:

    @Override
    public int hashCode() {
        return Objects.hashCode(_lockName);
    }

which is a change in hashCode() specification, hence runtime needs to be updated accordingly.



 Comments   
Comment by Robert Varga [ 18/Nov/18 ]

Actually this does not affect DataObject.hashCode(), so the runtime has no skin in the game.

Generated at Wed Feb 07 20:09:43 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.