-
Notifications
You must be signed in to change notification settings - Fork 18
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
use ByteString.toArrayUnsafe #308
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
finally gzos.close() | ||
ByteString.fromArrayUnsafe(baos.toByteArray) | ||
} | ||
|
||
override def uncompress(compressed: ByteString): ByteString = { | ||
val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray)) | ||
val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we have used compressed.asInputStream
? because toArrayUnsafe
can still create a new array in case the byteString is a rope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).
Something like https://github.com/apache/pekko-http/pull/539/files (this was reverted because of a bug in the hpack code - twitter/hpack#43).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).
thats unfortunate
this was reverted because of a bug in the hpack code - twitter/hpack#43
last commit of that library was 5 years ago. also it seems to be deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we can the netty 's Hpack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).
IMHO we could just require Pekko 1.1 in Pekko gRPC 1.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoids array copying