Skip to content

feat(vec): add extend() method for batch element insertion#419

Open
gabrielrondon wants to merge 2 commits intodfinity:mainfrom
gabrielrondon:feat/vec-extend
Open

feat(vec): add extend() method for batch element insertion#419
gabrielrondon wants to merge 2 commits intodfinity:mainfrom
gabrielrondon:feat/vec-extend

Conversation

@gabrielrondon
Copy link
Copy Markdown

Summary

  • Add BaseVec::extend(&[T]) and Vec::extend(&[T]) for appending multiple items in a single operation
  • Writes all items sequentially and updates the length once, reducing stable memory writes for the length field compared to repeated push()
  • Follows the same pattern as push(): serialize each item, write entry size, write data, then update length at the end
  • Includes unit tests for empty slice, basic usage, extend after push, multiple extends, and persistence across init/reinit

Closes #349

Add `BaseVec::extend()` and `Vec::extend()` for appending multiple items
in a single operation. Writes all items sequentially and updates the
length once, reducing stable memory writes compared to repeated push().

Closes dfinity#349
@gabrielrondon gabrielrondon requested a review from a team as a code owner March 23, 2026 23:47
@cla-idx-bot
Copy link
Copy Markdown

cla-idx-bot bot commented Mar 23, 2026

Dear @gabrielrondon,

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 CLA.

If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged.

— The DFINITY Foundation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add StableVec::extend method

1 participant