You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by GitBox <gi...@apache.org> on 2022/04/28 09:30:01 UTC

[GitHub] [wicket] theigl commented on a diff in pull request #513: WICKET-6977 More efficient hashcode computations

theigl commented on code in PR #513:
URL: https://github.com/apache/wicket/pull/513#discussion_r860679457


##########
wicket-core/src/main/java/org/apache/wicket/markup/head/AbstractJavaScriptReferenceHeaderItem.java:
##########
@@ -135,6 +135,11 @@ public boolean equals(Object o)
 	@Override
 	public int hashCode()
 	{
-		return Objects.hash(async, defer, charset);
+		// Not using `Objects.hash` for performance reasons
+		int result = super.hashCode();

Review Comment:
   I just noticed some inconsistencies:
   
   You added `super.hashCode` here, but not to `AbstractCssReferenceHeaderItem`. We should probably keep those two classes in sync.
   
   And the bigger issue: The contracts for equals and hashCode now don't align. If we add `super.hashCode` (which imho we should, because the super class contains `Objects.hash(markupId)`), we should also add `markupId` to the equals contract.
   
   @martin-g: Do you have any idea, why `AbstractJavaScriptReferenceHeaderItem` and `AbstractCssReferenceHeaderItem` do not currently user `super.equals` and `super.hashCode`. Do we intentionally ignore the `markupId` field in the super class? Your original commit for these implementations was 47aa1461d58b9a5660fc11032db952ce4df36a33.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org