paulirwin opened a new pull request, #1144:
URL: https://github.com/apache/lucenenet/pull/1144

   - [X] You've read the [Contributor 
Guide](https://github.com/apache/lucenenet/blob/main/CONTRIBUTING.md) and [Code 
of Conduct](https://www.apache.org/foundation/policies/conduct.html).
   - [X] You've included unit or integration tests for your change, where 
applicable.
   - [X] You've included inline docs for your change, where applicable.
   - [X] There's an open issue for the PR that you are making. If you'd like to 
propose a change, please [open an 
issue](https://github.com/apache/lucenenet/issues/new/choose) to discuss the 
change or find an existing issue.
   
   Optimize StemmerUtil for `ReadOnlySpan<char>`/`Span<char>`
   
   Fixes #1140
   
   ## Description
   
   This PR optimizes StemmerUtil's EndsWith and StartsWith for 
`ReadOnlySpan<char>`, and Delete and DeleteN for `Span<char>`. Additionally, 
this type was missing unit tests (including in latest Lucene AFAICT), so this 
adds some lucenenet-specific unit tests for this type.
   
   Note that the `len` parameters are not quite what you might expect on a 
naïve reading of the XML doc comments. It is not always equal to the input 
buffer length (otherwise we could just use `s.Length` and drop the parameter). 
Instead, it's Lucene's equivalent of what we would call a Slice in .NET. Any 
characters after `len` chars in the input buffer are treated as if they aren't 
there. While we could update every callsite of these methods to pass in a slice 
of the input buffer (via `.AsSpan(0, len)`) and drop the parameter, there are 
over 200 uses of these methods that would have to be updated (and kept in sync 
in future ports), and the additional overhead of creating an extra slice should 
be negligible as it's a stack-allocated ref struct. So I figured it would be 
best to keep the method signatures as close to the original as possible, 
without removing the `len` parameter.


-- 
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: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to