JD557 commented on code in PR #1247:
URL: https://github.com/apache/pekko/pull/1247#discussion_r1555436494
##########
actor/src/main/scala-2.13/org/apache/pekko/util/ByteString.scala:
##########
@@ -702,6 +728,33 @@ object ByteString {
}
}
+ override def indexOf(elem: Byte, from: Int): Int = {
+ if (from >= length) -1
+ else {
+ val byteStringsSize = bytestrings.size
+
+ @tailrec
+ def find(bsIdx: Int, relativeIndex: Int, bytesPassed: Int): Int = {
+ if (bsIdx >= byteStringsSize) -1
+ else {
+ val bs = bytestrings(bsIdx)
+
+ if (bs.length <= relativeIndex) {
+ find(bsIdx + 1, relativeIndex - bs.length, bytesPassed +
bs.length)
+ } else {
+ val subIndexOf = bs.indexOf(elem, relativeIndex)
+ if (subIndexOf < 0) {
+ val nextString = bsIdx + 1
+ find(nextString, relativeIndex - bs.length, bytesPassed +
bs.length)
Review Comment:
Went with this solution in e923cba. This is also what happens in the branch
above, so the code looks more symmetrical now. 👍
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]