From e50075508611e3cdabf60f37d9ba52f0be46c414 Mon Sep 17 00:00:00 2001 From: Nikolay Fedorovskikh Date: Thu, 7 Sep 2017 00:00:21 +0500 Subject: [PATCH] Remove double comparing of content out of the DefaultHttp2GoAwayFrame.equals() Motivation: In `DefaultHttp2GoAwayFrame.equals()` a content compared twice: explicitly and in the `super` method. Modifications: Remove explicit content comparision. Make `hashCode()` consistent with `equals()`. Result: A `DefaultHttp2GoAwayFrame.equals()` work faster. --- .../netty/handler/codec/http2/DefaultHttp2GoAwayFrame.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2GoAwayFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2GoAwayFrame.java index b1c5265ad083..77207673303f 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2GoAwayFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2GoAwayFrame.java @@ -160,15 +160,13 @@ public boolean equals(Object o) { return false; } DefaultHttp2GoAwayFrame other = (DefaultHttp2GoAwayFrame) o; - return super.equals(o) && errorCode == other.errorCode && content().equals(other.content()) - && extraStreamIds == other.extraStreamIds; + return errorCode == other.errorCode && extraStreamIds == other.extraStreamIds && super.equals(other); } @Override public int hashCode() { - int hash = 237395317; + int hash = super.hashCode(); hash = hash * 31 + (int) (errorCode ^ (errorCode >>> 32)); - hash = hash * 31 + content().hashCode(); hash = hash * 31 + extraStreamIds; return hash; }