Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.7k
feat: switch core http to okhttp#10069
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
raw:result.raw, | ||
toArrayBuffer: () => Uint8Array.from(result.raw.toByteArray()).buffer, | ||
raw: raw, | ||
toArrayBuffer: () => Uint8Array.from(raw.toByteArray()).buffer, |
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.
Uint8Array.from
iterates over each element of the source array and copies it to the new array.
If you use pass ajava.nio.ByteBuffer
as the argument it'll create the TypedArray from a pointer (O(1) performance and no extra memory allocation).
Creating a buffer from 1MB of data takes about ~700ms, wrapping it in ajava.nio.ByteBuffer
takes only 3ms
toArrayBuffer:()=>{constarr=raw.toByteArray();constbb=java.nio.ByteBuffer.wrap(arr);constbuffer=ArrayBuffer.from(bb);returnbuffer;},
WIP. Will fill details later.
Notes:
other than doing some body decoding in the main thread, this implementation already covers all of the current API + cancellation. Ideeally we should have the web spec AbortController ready for this