Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

trevnorris
Copy link
Contributor

The .parent property of the allocated buffer should remain undefined in
the case that it's not a slice.

R=@bnoordhuis

@@ -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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@chrisdickinson
Copy link
Contributor

One tiny nit, otherwise LGTM.

@indutny
Copy link
Member

indutny commented Mar 9, 2015

@trevnorris any point in writing test? Why changing this?

@trevnorris
Copy link
Contributor Author

@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 buffer === buffer.parent for large allocations.

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.
@trevnorris
Copy link
Contributor Author

@indutny I've included a test to check that it won't change in the future.

@indutny
Copy link
Member

indutny commented Mar 9, 2015

Thanks!

@indutny
Copy link
Member

indutny commented Mar 9, 2015

LGTM, I guess :)

trevnorris added a commit that referenced this pull request Mar 9, 2015
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>
@trevnorris
Copy link
Contributor Author

@chrisdickinson @indutny Thanks. Landed in 8070b1f.

@trevnorris trevnorris closed this Mar 9, 2015
@trevnorris trevnorris deleted the buf-fix-parent branch March 9, 2015 18:47
@rvagg rvagg mentioned this pull request Mar 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants