JD557 commented on PR #1247:
URL: https://github.com/apache/pekko/pull/1247#issuecomment-2056366328
Unfortunately, I don't think that would work, as the signature requires `[B
>: Byte]`. `B` could be `Any` and in that case we need the slow implementation
that falls back to `Object.equals` 😕
Code example:
```scala
case class MyByteSeq(data: List[Byte]) {
def fastIndexOf(byte: Byte): Int = data.indexOf(byte)
//def indexOf1[B >: Byte](x: B): Int = fastIndexOf(Byte.unbox(x)) // This
won't compile
def indexOf2[B >: Byte](x: B): Int =
fastIndexOf(Byte.unbox(x.asInstanceOf[Object])) // This can fail at runtime
def indexOf3[B >: Byte](x: B): Int = x match {
case b: Byte => fastIndexOf(b) // I think the pattern match already
unboxes it
case _ => ??? // I can't call fastIndexOf here, so I need a duplicated
version of the code anyway
}
}
```
--
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]