Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized general byte string array access #30263

Conversation

johanandren
Copy link
Member

Follow up on top of #30262
Refs #30257

Not sure this is needed, but just to jot the idea down.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR is currently being validated by Jenkins labels May 26, 2021
@akka-ci
Copy link

akka-ci commented May 26, 2021

Test FAILed.

@@ -271,6 +269,11 @@ object ByteString {
toCopy
}

override def toArrayUnsafe(): Array[Byte] = bytes

override def foldLeftArrayUnsafe[T](zero: T)(f: (T, Array[Byte], Int, Int) => T): T =
Copy link
Member

@patriknw patriknw May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this should be possible to use with proto.UnsafeByteOperations.unsafeWrap(bytes, offset, length), and proto.ByteString.concat.

An alternative could be to use the existing akka.ByteString.asByteBuffers.

Is there a public api to see if it's a ByteString1? Because then we could use that to choose between toArrayUnsafe or slightly more costly toArrayUnsafe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concrete ByteString classes are actually public, so you could use isInstanceOf to detect ByteString1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-attention Indicates a PR validation failure (set by CI infrastructure)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants