Skip to content

buffer: Don't assign .parent if none exists - #1109

Closed
trevnorris wants to merge 1 commit into
nodejs:v1.xfrom
trevnorris:buf-fix-parent
Closed

trevnorris wants to merge 1 commit into
nodejs:v1.xfrom
trevnorris:buf-fix-parent

Conversation

@trevnorris

Copy link
Copy Markdown
Contributor

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

R=@bnoordhuis

Comment thread lib/buffer.js

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

One tiny nit, otherwise LGTM.

@indutny

indutny commented Mar 9, 2015

Copy link
Copy Markdown
Member

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

@trevnorris

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

@indutny

indutny commented Mar 9, 2015

Copy link
Copy Markdown
Member

Thanks!

@indutny

indutny commented Mar 9, 2015

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

3 participants