pjfanning commented on code in PR #2148:
URL: https://github.com/apache/pekko/pull/2148#discussion_r2327366761
##########
actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala:
##########
@@ -247,17 +247,48 @@ object ByteString {
}
override def indexOf(elem: Byte): Int = indexOf(elem, 0)
+
+ @nowarn
override def indexOf(elem: Byte, from: Int): Int = {
- if (from >= length) -1
- else {
- var found = -1
- var i = math.max(from, 0)
- while (i < length && found == -1) {
- if (bytes(i) == elem) found = i
- i += 1
- }
- found
+ val fromIndex = math.max(0, from)
+ if (fromIndex >= length) return -1
+ val searchLength = length - fromIndex
+ var offset = fromIndex
+ val byteCount = searchLength & 7
+ if (byteCount > 0) {
Review Comment:
this is not a line by line port of the Netty code - I am pulling out
manageable chunks for the Netty code.
PlatformDependent and PlatformDependent0 are very large classes and I'm
trying to avoid porting too much.
In the end of the day, we might want to consider options like allowing an
optional ByteString implementation that wraps a ByteBuf or generally allowing
ByteString to be something where users can create their own as long as they
implement a defined trait/interface.
--
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]