| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@ChALkeR can you please review this ? 😊 |
Sorry, something went wrong.
|
@ChALkeR I removed length condition from documentation. |
Sorry, something went wrong.
Sorry, something went wrong.
|
@nodejs/buffer @nodejs/documentation |
Sorry, something went wrong.
| const nodeBuffers = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); | ||
|
|
||
| console.log(nodeBuffers.offset); | ||
| // prints: 344 |
There was a problem hiding this comment.
This is not always correct. It may return 0, and any subsequent call will probably increase it.
So it doesn't always print 344.
Sorry, something went wrong.
| // prints: 8192 | ||
|
|
||
| // But you can change it | ||
| Buffer.poolSize = 5; |
There was a problem hiding this comment.
This could be misleading. Changing Buffer.poolSize does have immediate effect on which buffers would be pooled, but it doesn't immediately change the size of the current pool, it changes the size of the next pool.
It does, however, take immediate effect for determining whether should the buffer be allocated from the pool or not.
Sorry, something went wrong.
|
@mritunjaygoutam12 Sorry for delay on this, that was mostly due to my personal issues :-/. Overall, I don't think that the code example is very useful -- it's the confusing part atm, as it seems for me. Perhaps we can get this to land faster without the code example at all. As for the remaining part -- it specifically mentions Buffer.from(array) for some reason, when in fact many other buffer operations are pooled. E.g. these are not covered: > Buffer.from('sdf').offset
280
> Buffer.concat([Buffer.from('xxx'), Buffer.from('yyy')]).offset
304
> Buffer.from(Buffer.from('sdf')).offset
320
> Buffer.from(new String('test')).offset
328The problem of the current documentation in master is that this section: Lines 100 to 103 in 17c6b1d makes it seem that only .allocUnsafe is pooled, when in fact mostly everything is pooled. Same for: Lines 597 to 609 in 17c6b1d Perhaps some of the rewording should touch those? Also, /cc @nodejs/tsc @nodejs/buffer @nodejs/security-wg -- what was the reason for making Buffer.alloc non-pooled, but Buffer.from pooled? Buffer.alloc could also benefit from pre-allocating zero-filled buffers, can't it? If providing pooled buffers is an issue, we shouldn't do that for everything. If it's not, perhaps we should just pool Buffer.alloc in a semver-major, so users won't be punished for using it instead of Buffer.allocUnsafe().fill()? |
Sorry, something went wrong.
There was a problem hiding this comment.
Some nits for consistency with other examples.
Sorry, something went wrong.
| const nodeBuffers = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); | ||
|
|
||
| console.log(nodeBuffers.offset); | ||
| // prints: 344 |
There was a problem hiding this comment.
| // prints: 344 | |
| // Prints: 344 |
Sorry, something went wrong.
|
|
||
| // Default Buffer.poolsize is 8192 | ||
| console.log(Buffer.poolSize); | ||
| // prints: 8192 |
There was a problem hiding this comment.
| // prints: 8192 | |
| // Prints: 8192 |
Sorry, something went wrong.
| const buf = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); | ||
|
|
||
| console.log(buf.offset); | ||
| // prints: 0 |
There was a problem hiding this comment.
| // prints: 0 | |
| // Prints: 0 |
Sorry, something went wrong.
|
@mritunjayz - can you address the review comments? |
Sorry, something went wrong.
|
@mritunjayz, are you still interested in working on the PR ? If not, let me know; I can pick this up and progress. |
Sorry, something went wrong.
|
@HarshithaKP yes, you can. Thanks |
Sorry, something went wrong.
|
This can be closed as the intention is fulfilled in #32703. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Checklist
#22139
Buffer.from will also use internal Buffer pool if it's size is less then Buffer.poolSize.