From 5cb45f13a3612010a30db0307be56001bd27e5c6 Mon Sep 17 00:00:00 2001 From: Agil <41694337+AgilAghamirzayev@users.noreply.github.com> Date: Fri, 13 Feb 2026 20:40:48 +0400 Subject: [PATCH] Refactor calculateHashCode method for clarity This will: 1. Mathematical Distribution (Collision Reduction) 2. Pipelining and CPU Caching 3. Avoiding "Method Heavy" Expressions Signed-off-by: Agil <41694337+AgilAghamirzayev@users.noreply.github.com> --- .../servlet/mvc/method/RequestMappingInfo.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java index bef16b4fc7d6..af50551949e1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfo.java @@ -541,11 +541,19 @@ public int hashCode() { @SuppressWarnings({"ConstantConditions", "NullAway", "removal"}) private int calculateHashCode() { - return (this.pathPatternsCondition != null ? this.pathPatternsCondition : this.patternsCondition).hashCode() * 31 + - this.methodsCondition.hashCode() + - this.paramsCondition.hashCode() + this.headersCondition.hashCode() + - this.consumesCondition.hashCode() + this.producesCondition.hashCode() + - this.versionCondition.hashCode() + this.customConditionHolder.hashCode(); + Object patternBase = (this.pathPatternsCondition != null) + ? this.pathPatternsCondition + : this.patternsCondition; + + int h = patternBase.hashCode(); + h = 31 * h + methodsCondition.hashCode(); + h = 31 * h + paramsCondition.hashCode(); + h = 31 * h + headersCondition.hashCode(); + h = 31 * h + consumesCondition.hashCode(); + h = 31 * h + producesCondition.hashCode(); + h = 31 * h + customConditionHolder.hashCode(); + + return h; } @Override