paulirwin commented on code in PR #1144:
URL: https://github.com/apache/lucenenet/pull/1144#discussion_r2395576471
##########
src/Lucene.Net.Analysis.Common/Analysis/Util/StemmerUtil.cs:
##########
@@ -111,14 +195,35 @@ public static bool EndsWith(char[] s, int len, char[]
suffix)
/// <param name="pos"> Position of character to delete </param>
/// <param name="len"> length of input buffer </param>
/// <returns> length of input buffer after deletion </returns>
- public static int Delete(char[] s, int pos, int len)
+ /// <remarks>
+ /// LUCENENET NOTE: This method has been converted to use <see
cref="Span{T}"/>.
+ /// Callers should prefer the overload without the <paramref
name="len"/> parameter and use a slice instead,
+ /// but this overload is provided for compatibility with existing code.
+ /// </remarks>
+ internal static int Delete(Span<char> s, int pos, int len)
{
- if (Debugging.AssertsEnabled) Debugging.Assert(pos < len);
- if (pos < len - 1) // don't arraycopy if asked to delete last
character
+ return Delete(s.Slice(0, len), pos);
+ }
+
+ /// <summary>
+ /// Delete n characters in-place
+ /// </summary>
+ /// <param name="s"> Input Buffer </param>
+ /// <param name="pos"> Position of character to delete </param>
+ /// <param name="nChars"> number of characters to delete </param>
+ /// <returns> length of input buffer after deletion </returns>
+ /// <remarks>
+ /// LUCENENET NOTE: This method has been converted to use <see
cref="Span{T}"/>.
+ /// </remarks>
+ public static int DeleteN(Span<char> s, int pos, int nChars)
+ {
+ if (Debugging.AssertsEnabled) Debugging.Assert(pos + nChars <=
s.Length);
+ if (pos + nChars < s.Length) // don't arraycopy if asked to delete
the last characters
{
- Arrays.Copy(s, pos + 1, s, pos, len - pos - 1);
+ // Arrays.Copy(s, pos + nChars, s, pos, len - pos - nChars);
+ s.Slice(pos + nChars, s.Length - pos -
nChars).CopyTo(s.Slice(pos, s.Length - pos - nChars));
Review Comment:
Good catch, will fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]