-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
src: redo unaligned access workaround #138
src: redo unaligned access workaround #138
Conversation
@indutny Would you be willing to review this PR? Thanks. |
if (encoding == UCS2) { | ||
assert(reinterpret_cast<uintptr_t>(buf) % sizeof(uint16_t) == 0 && | ||
"UCS2 buffer must be aligned on two-byte boundary."); | ||
return Encode(isolate, static_cast<const uint16_t*>(buf), len / 2); |
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.
Why using sizeof(uint16_t)
above, if you are using 2 here?
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.
Good point. How does 56fde66 look?
LGTM |
Introduce two-byte overloads of node::Encode() and StringBytes::Encode() that ensure that the input is suitably aligned. Revisits commit 535fec8 from yesterday.
Move the big endian to little endian conversion logic for UCS2 input from src/string_bytes.cc to src/node_buffer.cc; StringSlice() is the only function that actually needs it and with this commit, a second copy is avoided on big endian architectures.
beb3d1e
to
52fc406
Compare
R=@trevnorris