You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by Carter Kozak <ck...@ckozak.net> on 2022/01/12 13:59:25 UTC

Re: [logging-log4j2] 02/02: Use final and simpler hashcode generation through Objects.

I'd prefer if we didn't incur implicit array allocation cost generating a hash code. My preference is to keep the original implementation.

-ck

On Wed, Jan 12, 2022, at 08:50, ggregory@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> ggregory pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
> 
> commit 857eca786c2027469763e2fea93ed2b4a3c2b6c0
> Author: Gary Gregory <ga...@gmail.com>
> AuthorDate: Wed Jan 12 07:09:06 2022 -0500
> 
>     Use final and simpler hashcode generation through Objects.
> ---
> .../main/java/org/apache/logging/log4j/core/util/Source.java | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Source.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Source.java
> index 9674618..f28c8f8 100644
> --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Source.java
> +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Source.java
> @@ -143,15 +143,15 @@ public class Source {
>      }
>  
>      @Override
> -    public boolean equals(final Object o) {
> -        if (this == o) {
> +    public boolean equals(Object obj) {
> +        if (this == obj) {
>              return true;
>          }
> -        if (!(o instanceof Source)) {
> +        if (!(obj instanceof Source)) {
>              return false;
>          }
> -        final Source source = (Source) o;
> -        return Objects.equals(location, source.location);
> +        Source other = (Source) obj;
> +        return Objects.equals(location, other.location);
>      }
>  
>      /**
> @@ -208,7 +208,7 @@ public class Source {
>  
>      @Override
>      public int hashCode() {
> -        return 31 + Objects.hashCode(location);
> +        return Objects.hash(location);
>      }
>  
>      @Override
>