He-Pin commented on code in PR #1247:
URL: https://github.com/apache/pekko/pull/1247#discussion_r1554547925


##########
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:
   or we just inline it to the arguments.



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

Reply via email to