GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — src: add internal isArrayBufferDetached by anonrig · Pull Request #45568 · nodejs/node Conversation
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
dcee530 to
4d5d53b
Compare
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| function isArrayBufferDetached(value) { | ||
| if (ArrayBufferPrototypeGetByteLength(value) === 0) { | ||
| return _isArrayBufferDetached(value); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Crossing the JS-C++ boundary is gonna be slower than the current implementation although I'm not sure if this call in the zero length case is gonna be the primary bottleneck for any user code.
Did you consider implementing @jasnell's suggestion in #45512 (comment)? Seems like that approach would solve this problem without adding any performance overhead in any case.
One thing we might be able to do is add a hidden symbol to ArrayBuffer instances when we detach them in c++ land. Then we can have an isDetached check in js that checks the length and the presence of that symbol.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
IMHO, that is the perfect solution for performance, but I believe it's too hacky to maintain in the long term. I can't think of a good/maintainable way to enforce attaching the hidden symbol as a rule.
If it's the consensus @jasnell thinks is the best way, I'll be happy to implement it regardless.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM with or without a nit.
Adding a test would also be nice.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (ArrayBufferPrototypeGetByteLength(value) === 0) { | ||
| return _isArrayBufferDetached(value); | ||
| } | ||
|
|
||
| return false; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nit: the flow might look semantically better like this
| if (ArrayBufferPrototypeGetByteLength(value) === 0) { | |
| return _isArrayBufferDetached(value); | |
| } | |
| return false; | |
| if (ArrayBufferPrototypeGetByteLength(value) !== 0) { | |
| return false; | |
| } | |
| return _isArrayBufferDetached(value); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in 9a8d82b |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
PR-URL: #45568 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
PR-URL: #45568 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
PR-URL: #45568 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
PR-URL: #45568 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
PR-URL: #45568 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.