lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [20/26] lucenenet git commit: Lucene.Net.Core.Documents.Document: Fixed bug in RemoveField (was removing the last match instead of the first one) and added StringComparison.Ordinal for Equals comparisons
Date Wed, 08 Mar 2017 18:23:56 GMT
Lucene.Net.Core.Documents.Document: Fixed bug in RemoveField (was removing the last match instead
of the first one) and added StringComparison.Ordinal for Equals comparisons


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/52985116
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/52985116
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/52985116

Branch: refs/heads/api-work
Commit: 52985116b54a40324c529144d91ce4098367779e
Parents: b354117
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Mar 8 19:27:56 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Mar 8 19:27:56 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Document/Document.cs | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/52985116/src/Lucene.Net.Core/Document/Document.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/Document.cs b/src/Lucene.Net.Core/Document/Document.cs
index 0918802..3bde293 100644
--- a/src/Lucene.Net.Core/Document/Document.cs
+++ b/src/Lucene.Net.Core/Document/Document.cs
@@ -1,5 +1,6 @@
 using Lucene.Net.Index;
 using Lucene.Net.Util;
+using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
@@ -83,13 +84,13 @@ namespace Lucene.Net.Documents
         /// </summary>
         public void RemoveField(string name)
         {
-            for (int i = fields.Count - 1; i >= 0; i--)
+            for (int i = 0; i < fields.Count - 1; i++)
             {
                 IIndexableField field = fields[i];
 
-                if (field.Name.Equals(name))
+                if (field.Name.Equals(name, StringComparison.Ordinal))
                 {
-                    fields.RemoveAt(i);
+                    fields.Remove(field);
                     return;
                 }
             }
@@ -110,9 +111,9 @@ namespace Lucene.Net.Documents
             {
                 IIndexableField field = fields[i];
 
-                if (field.Name.Equals(name))
+                if (field.Name.Equals(name, StringComparison.Ordinal))
                 {
-                    fields.RemoveAt(i);
+                    fields.Remove(field);
                 }
             }
         }
@@ -131,7 +132,7 @@ namespace Lucene.Net.Documents
 
             foreach (IIndexableField field in fields)
             {
-                if (field.Name.Equals(name))
+                if (field.Name.Equals(name, StringComparison.Ordinal))
                 {
                     BytesRef bytes = field.GetBinaryValue();
 
@@ -157,7 +158,7 @@ namespace Lucene.Net.Documents
         {
             foreach (IIndexableField field in fields)
             {
-                if (field.Name.Equals(name))
+                if (field.Name.Equals(name, StringComparison.Ordinal))
                 {
                     BytesRef bytes = field.GetBinaryValue();
                     if (bytes != null)
@@ -178,7 +179,7 @@ namespace Lucene.Net.Documents
         {
             foreach (IIndexableField field in fields)
             {
-                if (field.Name.Equals(name))
+                if (field.Name.Equals(name, StringComparison.Ordinal))
                 {
                     return field;
                 }
@@ -198,7 +199,7 @@ namespace Lucene.Net.Documents
             var result = new List<IIndexableField>();
             foreach (IIndexableField field in fields)
             {
-                if (field.Name.Equals(name))
+                if (field.Name.Equals(name, StringComparison.Ordinal))
                 {
                     result.Add(field);
                 }
@@ -238,7 +239,7 @@ namespace Lucene.Net.Documents
             var result = new List<string>();
             foreach (IIndexableField field in fields)
             {
-                if (field.Name.Equals(name) && field.GetStringValue() != null)
+                if (field.Name.Equals(name, StringComparison.Ordinal) && field.GetStringValue()
!= null)
                 {
                     result.Add(field.GetStringValue());
                 }
@@ -265,7 +266,7 @@ namespace Lucene.Net.Documents
         {
             foreach (IIndexableField field in fields)
             {
-                if (field.Name.Equals(name, System.StringComparison.Ordinal) && field.GetStringValue()
!= null)
+                if (field.Name.Equals(name, StringComparison.Ordinal) && field.GetStringValue()
!= null)
                 {
                     return field.GetStringValue();
                 }


Mime
View raw message