You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/10/03 23:58:51 UTC
[lucenenet] 06/08: Lucene.Net.Util.StringHelper: Marked static,
removed private ctor, made StartsWith(), EndsWith(), BytesDifference(),
and SliceEquals() into extension methods
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 528572277bd0e3b953ed1f2c789a57a67d744aa4
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sun Oct 4 03:07:18 2020 +0700
Lucene.Net.Util.StringHelper: Marked static, removed private ctor, made StartsWith(), EndsWith(), BytesDifference(), and SliceEquals() into extension methods
---
src/Lucene.Net/Util/StringHelper.cs | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/Lucene.Net/Util/StringHelper.cs b/src/Lucene.Net/Util/StringHelper.cs
index 0e32c3f..eb2e500 100644
--- a/src/Lucene.Net/Util/StringHelper.cs
+++ b/src/Lucene.Net/Util/StringHelper.cs
@@ -28,7 +28,7 @@ namespace Lucene.Net.Util
/// <para/>
/// @lucene.internal
/// </summary>
- public abstract class StringHelper
+ public static class StringHelper // LUCENENET specific - marked static and removed private constructor
{
/// <summary>
/// Pass this as the seed to <see cref="Murmurhash3_x86_32(byte[], int, int, int)"/>. </summary>
@@ -69,7 +69,7 @@ namespace Lucene.Net.Util
/// <param name="left"> The first <see cref="BytesRef"/> to compare. </param>
/// <param name="right"> The second <see cref="BytesRef"/> to compare. </param>
/// <returns> The number of common elements. </returns>
- public static int BytesDifference(BytesRef left, BytesRef right)
+ public static int BytesDifference(this BytesRef left, BytesRef right) // LUCENENET specific - converted to extension method
{
int len = left.Length < right.Length ? left.Length : right.Length;
var bytesLeft = left.Bytes;
@@ -86,10 +86,6 @@ namespace Lucene.Net.Util
return len;
}
- private StringHelper()
- {
- }
-
/// <summary> Returns a <see cref="T:IComparer{string}"/> over versioned strings such as X.YY.Z
/// <para/>
/// @lucene.internal
@@ -154,7 +150,7 @@ namespace Lucene.Net.Util
/// The expected prefix </param>
/// <returns> Returns <c>true</c> if the <paramref name="ref"/> starts with the given <paramref name="prefix"/>.
/// Otherwise <c>false</c>. </returns>
- public static bool StartsWith(BytesRef @ref, BytesRef prefix) // LUCENENET TODO: API - convert to extension method
+ public static bool StartsWith(this BytesRef @ref, BytesRef prefix) // LUCENENET specific - converted to extension method
{
return SliceEquals(@ref, prefix, 0);
}
@@ -169,12 +165,12 @@ namespace Lucene.Net.Util
/// The expected suffix </param>
/// <returns> Returns <c>true</c> if the <paramref name="ref"/> ends with the given <paramref name="suffix"/>.
/// Otherwise <c>false</c>. </returns>
- public static bool EndsWith(BytesRef @ref, BytesRef suffix) // LUCENENET TODO: API - convert to extension method
+ public static bool EndsWith(this BytesRef @ref, BytesRef suffix) // LUCENENET specific - converted to extension method
{
return SliceEquals(@ref, suffix, @ref.Length - suffix.Length);
}
- private static bool SliceEquals(BytesRef sliceToTest, BytesRef other, int pos)
+ private static bool SliceEquals(this BytesRef sliceToTest, BytesRef other, int pos) // LUCENENET specific - converted to extension method
{
if (pos < 0 || sliceToTest.Length - pos < other.Length)
{