Skip to content

feat: add an impl of Memory that uses ic0 API#2

Merged
roman-kashitsyn merged 1 commit intomainfrom
roman-ic0-stable-memory
Mar 10, 2022
Merged

feat: add an impl of Memory that uses ic0 API#2
roman-kashitsyn merged 1 commit intomainfrom
roman-ic0-stable-memory

Conversation

@roman-kashitsyn
Copy link
Copy Markdown
Contributor

No description provided.

@roman-kashitsyn roman-kashitsyn force-pushed the roman-ic0-stable-memory branch from bf7aac1 to 8e2bd8a Compare March 10, 2022 09:00
@roman-kashitsyn roman-kashitsyn merged commit 9a72140 into main Mar 10, 2022
@roman-kashitsyn roman-kashitsyn deleted the roman-ic0-stable-memory branch March 10, 2022 09:01
ielashi added a commit that referenced this pull request Jun 7, 2024
## Problem

`BaseVec`, which is the underlying data structure used by `StableVec`
and `StableMinHeap` provides a `set` method that allows the caller to
change the value of an element at a specified index.

The `set` method used the `memory.write` method, which assumed that
there is always enough memory to rewrite the element. This assumption
would've been fine if other methods like `push` always allocated the
maximum amount of space for every element. Currently though, `push`
only allocates the amount needed to store the element that's being
pushed.

## Solution

There are two possible solutions:

1) Modify `push` to always allocate the maximum size of an element.
2) Modify `set` to grow the memory as needed as it's rewriting an element.

This commit implements solution #2, which was both simpler and more
performant.
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.

1 participant