buffer: make Buffer binding and prototype setup more straight-forward#25292
Closed
joyeecheung wants to merge 2 commits intonodejs:masterfrom
Closed
buffer: make Buffer binding and prototype setup more straight-forward#25292joyeecheung wants to merge 2 commits intonodejs:masterfrom
joyeecheung wants to merge 2 commits intonodejs:masterfrom
Conversation
Instead of exposing it in `lib/internal/buffer.js` after deleting it from the binding and then do the initialization in `lib/buffer.js`, which results in an implicit dependency on the order in which these modules are loaded.
Instead of exposing the Buffer prototype methods through an object in `internal/buffer.js` and then iterating over it to put the methods on the prototype, create a function in `internal/buffer.js` to do this. Also moves the creaton of the `FastBuffer` class into `internal/buffer.js` and expose it directly instead of writing it onto that module later.
Member
Author
Member
Author
|
Ping @nodejs/process @nodejs/buffer can I have some review please? |
joyeecheung
commented
Jan 2, 2019
| class FastBuffer extends Uint8Array {} | ||
|
|
||
| function addBufferPrototypeMethods(proto) { | ||
| proto.readUIntLE = readUIntLE; |
Member
Author
There was a problem hiding this comment.
Another way to do this is to put all these to the prototype of FastBuffer, I am not sure if there are any concerns about edge cases though
Member
Author
|
Ping again..according to the GitHub reviewer recommendations: @BridgeAR @TimothyGu @addaleax |
Member
Author
jasnell
approved these changes
Jan 9, 2019
BridgeAR
approved these changes
Jan 10, 2019
joyeecheung
added a commit
that referenced
this pull request
Jan 10, 2019
Instead of exposing it in `lib/internal/buffer.js` after deleting it from the binding and then do the initialization in `lib/buffer.js`, which results in an implicit dependency on the order in which these modules are loaded. PR-URL: #25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
joyeecheung
added a commit
that referenced
this pull request
Jan 10, 2019
Instead of exposing the Buffer prototype methods through an object in `internal/buffer.js` and then iterating over it to put the methods on the prototype, create a function in `internal/buffer.js` to do this. Also moves the creaton of the `FastBuffer` class into `internal/buffer.js` and expose it directly instead of writing it onto that module later. PR-URL: #25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Member
Author
|
Landed in fa5af0d...842a35f |
Member
|
@joyeecheung Can you look into backporting this to v11.x-staging? |
Member
|
I pushed a backport directly onto v11.x-staging. There was just a minor conflict in |
BridgeAR
pushed a commit
that referenced
this pull request
Jan 16, 2019
Instead of exposing it in `lib/internal/buffer.js` after deleting it from the binding and then do the initialization in `lib/buffer.js`, which results in an implicit dependency on the order in which these modules are loaded. PR-URL: #25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR
pushed a commit
that referenced
this pull request
Jan 16, 2019
Instead of exposing the Buffer prototype methods through an object in `internal/buffer.js` and then iterating over it to put the methods on the prototype, create a function in `internal/buffer.js` to do this. Also moves the creaton of the `FastBuffer` class into `internal/buffer.js` and expose it directly instead of writing it onto that module later. PR-URL: #25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Merged
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Jan 16, 2019
Instead of exposing it in `lib/internal/buffer.js` after deleting it from the binding and then do the initialization in `lib/buffer.js`, which results in an implicit dependency on the order in which these modules are loaded. PR-URL: nodejs#25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Jan 16, 2019
Instead of exposing the Buffer prototype methods through an object in `internal/buffer.js` and then iterating over it to put the methods on the prototype, create a function in `internal/buffer.js` to do this. Also moves the creaton of the `FastBuffer` class into `internal/buffer.js` and expose it directly instead of writing it onto that module later. PR-URL: nodejs#25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Jan 17, 2019
Instead of exposing it in `lib/internal/buffer.js` after deleting it from the binding and then do the initialization in `lib/buffer.js`, which results in an implicit dependency on the order in which these modules are loaded. PR-URL: nodejs#25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Jan 17, 2019
Instead of exposing the Buffer prototype methods through an object in `internal/buffer.js` and then iterating over it to put the methods on the prototype, create a function in `internal/buffer.js` to do this. Also moves the creaton of the `FastBuffer` class into `internal/buffer.js` and expose it directly instead of writing it onto that module later. PR-URL: nodejs#25292 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
buffer: move initialization of buffer prototype into node.js
Instead of exposing
setBufferJSinlib/internal/buffer.jsafter deletingit from the binding and then do the initialization in
lib/buffer.js, which results in an implicit dependency onthe order in which these modules are loaded.
buffer: move Buffer prototype wiring into internal/buffer.js
Instead of exposing the Buffer prototype methods through an
object in
internal/buffer.jsand then iterating over itto put the methods on the prototype, create a function
in
internal/buffer.jsto do this.Also moves the creation of the
FastBufferclass intointernal/buffer.jsand expose it directly instead ofwriting it onto that module later.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes