| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
what about possibly placing this in lib/internal/buffer-transcode.js and conditionally require()'ing it. purely cosmetic though, to prevent an extra level of indent. or you could just return early. :)
if (!process.binding('config').hasIntl)
return;
Sorry, something went wrong.
There was a problem hiding this comment.
We going to have a complaint about not supporting SharedArrayBuffer for this?
Sorry, something went wrong.
There was a problem hiding this comment.
Eventually, perhaps. Not too worried about that for now.
Sorry, something went wrong.
|
Updated |
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe give an example of transcoding is not possible?
Sorry, something went wrong.
There was a problem hiding this comment.
Hm – this could be a ThrowICUError function, right?
Sorry, something went wrong.
There was a problem hiding this comment.
This is fine but at some point this might become a member of the MaybeStackBuffer class? I realize that would conflict a bit with the MaybeStackBuffer<UChar> overload, maybe leave a TODO here?
Sorry, something went wrong.
There was a problem hiding this comment.
Is that final to residue from editing?
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, slight brain malfunction there I think ;-)
Sorry, something went wrong.
There was a problem hiding this comment.
Mhhh this returns a string or a Buffer depending on the target encoding? I don’t think binary-to-text encodings should be allowed here, .toString() is the right method for them.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, you're right. I'll pull these back out.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM, nice!
Sorry, something went wrong.
There was a problem hiding this comment.
Could this use SwapBytes16?
Sorry, something went wrong.
There was a problem hiding this comment.
(ditto)
Sorry, something went wrong.
There was a problem hiding this comment.
The 1024 seem kind of magic here, although I realize that is largely my fault. 😄 (Not sure if there’s anything to do about that)
Sorry, something went wrong.
There was a problem hiding this comment.
Should be fixed now!
Sorry, something went wrong.
There was a problem hiding this comment.
Style: s/from_enc/fromEncoding/ and s/to_enc/toEncoding/. Ditto for cnv_from and cnv_to.
Sorry, something went wrong.
There was a problem hiding this comment.
I realize you adapted this code from elsewhere but using snprintf() to format the error message will be much more efficient.
Sorry, something went wrong.
There was a problem hiding this comment.
Needs a if (e.Empty()) return Local<Value>();.
Sorry, something went wrong.
There was a problem hiding this comment.
I think this should be if (!ret.Empty()) buf->Release(); - it's leaking memory now when the buffer can't be created.
Sorry, something went wrong.
There was a problem hiding this comment.
Ditto.
Sorry, something went wrong.
There was a problem hiding this comment.
Same as above: strict aliasing violation and prone to crashing.
Sorry, something went wrong.
There was a problem hiding this comment.
It seems like there is ample opportunity to share code between Ucs2FromUtf8 and Utf8FromUcs2, they are 80% identical.
Sorry, something went wrong.
There was a problem hiding this comment.
Perhaps. For now I'm more inclined to keep these separate as it makes finding and tweaking bugs a bit easier. I'll take another pass in a separate PR to condense things down.
Sorry, something went wrong.
There was a problem hiding this comment.
Shouldn't this also reset length_?
Sorry, something went wrong.
There was a problem hiding this comment.
If you move this into a common header, you might want to give it a slightly less generic name; e.g. SPREAD_BUFFER_ARG.
Sorry, something went wrong.
There was a problem hiding this comment.
Just remove the 'defines' block instead of commenting it out.
Sorry, something went wrong.
|
New CI: https://ci.nodejs.org/job/node-test-pull-request/4503/ |
Sorry, something went wrong.
|
Another CI run after cleanups: https://ci.nodejs.org/job/node-test-pull-request/4507/ ... that last run was less than successful.... |
Sorry, something went wrong.
|
CI looks good. @bnoordhuis PTAL... LGTY? |
Sorry, something went wrong.
There was a problem hiding this comment.
if you're returning empty handles as an indicator it's probably be more "V8-ish" have the return signature as a MaybeLocal<Value> instead. been trying to do that in other locations myself.
Sorry, something went wrong.
There was a problem hiding this comment.
creating Local<Value>'s but there's no HandleScope. if this callback is expected to always be called within an existing HandleScope (like MakeCallback), mind putting a comment at the top. also like MakeCallback (see src/node.h).
Sorry, something went wrong.
There was a problem hiding this comment.
if we know this is a v8::Object then can use e.As<Object>(). that's also more explicit that no extra handle is being created.
Sorry, something went wrong.
There was a problem hiding this comment.
The new v8::Maybe<T> API for v8::Object::Set() is annoying and ugly, but if if we're going to use some of the new API might as well use all of it.
Sorry, something went wrong.
There was a problem hiding this comment.
if you're manipulating the original memory, why bother take a copy?
Sorry, something went wrong.
There was a problem hiding this comment.
if this operation fails, do we want to abort or throw?
Sorry, something went wrong.
There was a problem hiding this comment.
for future performance enhancement, detect the alignment of the pointer and perform as many swaps that can be done in a single go.
Sorry, something went wrong.
There was a problem hiding this comment.
i'm a little confused by this whole object, but right here if we're converting ascii to latin1 shouldn't we be passing 'latin1' as the encoding argument to Buffer.from()?
Sorry, something went wrong.
|
@bnoordhuis ... ok, reworked the implementation with an eye towards simplification and reducing duplication. PTAL |
Sorry, something went wrong.
Sorry, something went wrong.
|
Thank you for the follow up review @addaleax. Will get this landed tomorrow if there are no further objections. |
Sorry, something went wrong.
Add buffer.transcode(source, from, to) method. Primarily uses ICU to transcode a buffer's content from one of Node.js' supported encodings to another. Originally part of a proposal to add a new unicode module. Decided to refactor the approach towrds individual PRs without a new module. Refs: nodejs#8075
|
New CI run after squashing: https://ci.nodejs.org/job/node-test-pull-request/4665/ |
Sorry, something went wrong.
|
green except for unrelated failures. landing |
Sorry, something went wrong.
Add buffer.transcode(source, from, to) method. Primarily uses ICU to transcode a buffer's content from one of Node.js' supported encodings to another. Originally part of a proposal to add a new unicode module. Decided to refactor the approach towrds individual PRs without a new module. Refs: #8075 PR-URL: #9038 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Add buffer.transcode(source, from, to) method. Primarily uses ICU to transcode a buffer's content from one of Node.js' supported encodings to another. Originally part of a proposal to add a new unicode module. Decided to refactor the approach towrds individual PRs without a new module. Refs: #8075 PR-URL: #9038 Reviewed-By: Anna Henningsen <anna@addaleax.net>
|
If this is backported to any of the other release lines, it needs to come with #9838 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
buffer
Description of change
Add buffer.transcode(source, from, to) method. Primarily uses ICU to transcode a buffer's content from one of Node.js' supported encodings to another.
Originally part of a proposal to add a new unicode module. Decided to refactor the approach towrds individual PRs without a new module.
Refs: #8075
/cc @trevnorris @addaleax