Skip to content

Commit

Permalink
buffer: fix pool offset adjustment
Browse files Browse the repository at this point in the history
If the Buffer allocation isn't a slice then there's no need to adjust
the pool offset after realloc'ing the space available.

Fixes: 6462519 "buffer, doc: misc. fix and cleanup"
  • Loading branch information
trevnorris committed Feb 16, 2015
1 parent 77f3586 commit c6fd2c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ function Buffer(subject, encoding) {
var prevLen = this.length;
this.length = len;
truncate(this, this.length);
poolOffset -= (prevLen - len);
// Only need to readjust the poolOffset if the allocation is a slice.
if (this.parent != undefined)
poolOffset -= (prevLen - len);
}

} else if (subject instanceof Buffer) {
Expand Down

6 comments on commit c6fd2c5

@Fishrock123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevnorris
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fishrock123 I assume this is for anyone else that sees this commit? Because I'm fully aware of how to contribute.

@bnoordhuis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what @Fishrock123 is trying to say is that you're supposed to open a PR and have someone review it, not land the change sight unseen.

@Fishrock123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, what ben said. I know you're used to node haha. :)

@mikeal
Copy link
Contributor

@mikeal mikeal commented on c6fd2c5 Feb 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the policy pertains to "significant changes" if I remember correctly. No need to jam up simple 2 line fixes with extraneous process when they are landed by contributors who have been working on the code base for years. If something ever did land that shouldn't git is pretty good at backing things out ;)

@bnoordhuis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Significant change" is a slippery slope and it's not like a one-liner can't contain bugs. Everyone files PRs now and I do believe it has had a positive impact on code quality.

Please sign in to comment.