-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
buffer: make Buffer binding and prototype setup more straight-forward #25292
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.
Ping @nodejs/process @nodejs/buffer can I have some review please? |
class FastBuffer extends Uint8Array {} | ||
|
||
function addBufferPrototypeMethods(proto) { | ||
proto.readUIntLE = readUIntLE; |
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.
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
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.
I am fine either way.
Ping again..according to the GitHub reviewer recommendations: @BridgeAR @TimothyGu @addaleax |
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.
Code LGTM
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Landed in fa5af0d...842a35f |
@joyeecheung Can you look into backporting this to v11.x-staging? |
I pushed a backport directly onto v11.x-staging. There was just a minor conflict in |
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
buffer: move initialization of buffer prototype into node.js
Instead of exposing
setBufferJS
inlib/internal/buffer.js
after 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.js
and then iterating over itto put the methods on the prototype, create a function
in
internal/buffer.js
to do this.Also moves the creation of the
FastBuffer
class intointernal/buffer.js
and expose it directly instead ofwriting it onto that module later.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes