NightOwl888 commented on issue #719:
URL: https://github.com/apache/lucenenet/issues/719#issuecomment-1290729659

   Nope. The commit 
https://github.com/apache/lucenenet/commit/bebbae94145916520972ce25b3ebc2778db7c699#diff-ff3f44867a5688ccfea635f8d3c39fca938e698e60df8b6016a329a0e32fb40c
 is converting from `limit` (exclusive end index) to `length` to match .NET 
APIs. However, the overload of `Replace()` that is being called had the first 2 
parameters `start` and `limit` which were both set to the variable `dest` (now 
renamed to `destinationIndex`). To convert using the formula:
   
   ```length = limit - start```
   
   We end up with:
   
   ```length = dest - dest```
   
   Renamed:
   
   ```length = destinationIndex - destinationIndex```
   
   This basically makes the `Replace()` method into an effective `Insert()` 
operation at `destinationIndex` for `text.Length` characters. At the end of the 
day, having the same value for both `start` and `limit` (or `end`) in Java 
means use a zero-length slice of the array.
   
   Although the `length` of the "value to replace" is always `0`, I find it is 
helpful to show your work in the conversion rather than simply setting it to 
`0`. There are several other places where we are subtracting `0` from `limit` 
(or `end`) just to show that it was converted, even though this obviously has 
no real effect on the application.
   


-- 
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]

Reply via email to