You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For consistency with CharSequence.indexOf (which out functions are mimicking), Source.indexOf(BS, Int) and Buffer.indexOf(BS, Int) should return a start index (0, by default) when byte string to search is empty.
Currently, both functions return 0 (disregard startIndex value).
The text was updated successfully, but these errors were encountered:
I don't think you can get away with returning the start index without first requiring at least that much data to be loaded.
The CharSequence one doesn't quite return the start index if the search string is empty and there's not enough data. Doing "short".indexOf("", 10) will return 5 and not 10.
I don't love the idea of returning whatever arbitrary maximum index is available from the Source/Buffer because it can be more non-determinstic as opposed to a fully-static String, so I think the only choice might be to require the data.
After all, I convinced myself that indexOf(empty byte string) should behave the same way CharSequence.indexOf("").
That means, Buffer|Source.indexOf(ByteString, someIndex) == max(0, min(someIndex, buffer.size)).
For Source, we'll try to fetch max(0, someIndex) bytes first.
For consistency with
CharSequence.indexOf
(which out functions are mimicking),Source.indexOf(BS, Int)
andBuffer.indexOf(BS, Int)
should return a start index (0
, by default) when byte string to search is empty.Currently, both functions return
0
(disregardstartIndex
value).The text was updated successfully, but these errors were encountered: