This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 308614837094d1bed4d6dbc70ee785e0c30cc94d Author: Shad Storhaug <[email protected]> AuthorDate: Mon Jun 29 13:31:05 2020 +0700 Lucene.Net.Index.Term: Optimized equality checking (#295, #261) --- src/Lucene.Net/Index/Term.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Lucene.Net/Index/Term.cs b/src/Lucene.Net/Index/Term.cs index fe323f9..3183474 100644 --- a/src/Lucene.Net/Index/Term.cs +++ b/src/Lucene.Net/Index/Term.cs @@ -114,8 +114,9 @@ namespace Lucene.Net.Index public override bool Equals(object obj) { - Term t = obj as Term; - return this.Equals(t); + if (obj is Term other) + return Equals(other); + return false; } public override int GetHashCode() @@ -162,21 +163,15 @@ namespace Lucene.Net.Index public bool Equals(Term other) { - if (object.ReferenceEquals(null, other)) - { - return object.ReferenceEquals(null, this); - } - if (object.ReferenceEquals(this, other)) - { + if (other is null) + return false; + if (ReferenceEquals(this, other)) return true; - } if (this.GetType() != other.GetType()) - { return false; - } - if (string.Compare(this.Field, other.Field, StringComparison.Ordinal) != 0) + if (!StringComparer.Ordinal.Equals(Field, other.Field)) { return false; } @@ -188,7 +183,7 @@ namespace Lucene.Net.Index return false; } } - else if (!Bytes.Equals(other.Bytes)) + else if (!Bytes.BytesEquals(other.Bytes)) { return false; }
