pjfanning commented on code in PR #1247: URL: https://github.com/apache/pekko/pull/1247#discussion_r1552436948
########## actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala: ########## @@ -790,6 +843,30 @@ sealed abstract class ByteString extends IndexedSeq[Byte] with IndexedSeqOptimiz // optimized in subclasses override def indexOf[B >: Byte](elem: B): Int = indexOf(elem, 0) + // optimized version of indexOf for bytes, optimized in subclasses + /** + * Finds index of first occurrence of some byte in this ByteString after or at some start index. + * + * Similar to indexOf, but it avoids boxing if the value is already a byte. + * + * @param elem the element value to search for. + * @param from the start index + * @return the index `>= from` of the first element of this ByteString that is equal (as determined by `==`) + * to `elem`, or `-1`, if none exists. + */ + def indexOf(elem: Byte, from: Int): Int = indexOf(elem, from) Review Comment: Don't worry about the @mdedetrich project? This repo is the source of truth for ByteString. He will copy any changes from this repo if he thinks that they are useful. The Pekko ByteString is not going away soon. The idea that it will end up in the Scala lib is not gaining traction and even it does it may not end up in every Scala version that Pekko needs it in and it may end up working differently to the way the Pekko one does. ########## actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala: ########## @@ -790,6 +843,30 @@ sealed abstract class ByteString extends IndexedSeq[Byte] with IndexedSeqOptimiz // optimized in subclasses override def indexOf[B >: Byte](elem: B): Int = indexOf(elem, 0) + // optimized version of indexOf for bytes, optimized in subclasses + /** + * Finds index of first occurrence of some byte in this ByteString after or at some start index. + * + * Similar to indexOf, but it avoids boxing if the value is already a byte. + * + * @param elem the element value to search for. + * @param from the start index + * @return the index `>= from` of the first element of this ByteString that is equal (as determined by `==`) + * to `elem`, or `-1`, if none exists. + */ + def indexOf(elem: Byte, from: Int): Int = indexOf(elem, from) Review Comment: Don't worry about the @mdedetrich project. This repo is the source of truth for ByteString. He will copy any changes from this repo if he thinks that they are useful. The Pekko ByteString is not going away soon. The idea that it will end up in the Scala lib is not gaining traction and even it does it may not end up in every Scala version that Pekko needs it in and it may end up working differently to the way the Pekko one does. -- 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]
