Efficient addArray method#388
Efficient addArray method#388tomijaga wants to merge 2 commits intocaffeinelabs:masterfrom tomijaga:development
Conversation
Add Doc comments to fromArray function
|
Dear @tomijaga, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA1. If you decide to agree with it, please visit this issue and read the instructions there. — The DFINITY Foundation Footnotes
|
|
Thanks for this PR! Seems very reasonable, except the API is getting large and presenting lots of choices to the programmer now. The situation addressed here is adding an array to a buffer. They could either use this proposed functionality, or use what is there now in two steps: (1) create a second buffer from their array (via newly merged The upside of this two-step approach is that it does not require growing the API of the Buffer class, which will enlarge the representation of every buffer instance. The downside is that the two-step approach will not avoid the extra resizing, which is the whole point of this PR. But to address that, we could try to absorb some of this clever logic here ( WDYT? |
|
I think it would be a great idea to add the functionality from this PR to the I'm curious, however, about how Regarding the update for the |
d52aecd to
08507fc
Compare
An efficient solution for the
addArray()method addressed in this comment#368 (comment)
The previous solution used the
add()method, which could resize the array more than once.This PR solves this problem by only resizing the buffer once.