-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: Don't assign .parent if none exists #1109
Conversation
@@ -141,7 +141,10 @@ function fromJsonObject(that, object) { | |||
|
|||
function allocate(that, length) { | |||
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1; | |||
that.parent = fromPool ? palloc(that, length) : alloc(that, length); | |||
if (fromPool) |
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.
would it be alright to explicitly assign .parent = null
above here so we can keep the same object shape?
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.
@chrisdickinson That's already done by setting this.parent = undefined
in the constructor.
One tiny nit, otherwise LGTM. |
@trevnorris any point in writing test? Why changing this? |
@indutny This is how it operated before a recent change by @bnoordhuis. I'm reverting back to the way it worked. The way it is now |
The .parent property of the allocated buffer should remain undefined in the case that it's not a slice. Also included test to verify this.
09ed699
to
97d7970
Compare
@indutny I've included a test to check that it won't change in the future. |
Thanks! |
LGTM, I guess :) |
The .parent property of the allocated buffer should remain undefined in the case that it's not a slice. Also included test to verify this. PR-URL: #1109 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
@chrisdickinson @indutny Thanks. Landed in 8070b1f. |
The .parent property of the allocated buffer should remain undefined in
the case that it's not a slice.
R=@bnoordhuis