Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove direct array accesses in experimental stable structures #2409

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ impl JsFn for NativeFunction {
.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();

stable_b_tree_maps[&memory_id].contains_key(&AzleStableBTreeMapKey { bytes: key })
stable_b_tree_maps
.get(&memory_id)
.unwrap()
.contains_key(&AzleStableBTreeMapKey { bytes: key })
})
.into()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ impl JsFn for NativeFunction {
let value_option = STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();

stable_b_tree_maps[&memory_id].get(&AzleStableBTreeMapKey { bytes: key })
stable_b_tree_maps
.get(&memory_id)
.unwrap()
.get(&AzleStableBTreeMapKey { bytes: key })
});

// TODO could we somehow encode the entire option here more easily
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl JsFn for NativeFunction {
.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();

stable_b_tree_maps[&memory_id].is_empty()
stable_b_tree_maps.get(&memory_id).unwrap().is_empty()
})
.into()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl JsFn for NativeFunction {

let items: Vec<Vec<Vec<u8>>> = STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();
let stable_b_tree_map = &stable_b_tree_maps[&memory_id];
let stable_b_tree_map = stable_b_tree_maps.get(&memory_id).unwrap();

stable_b_tree_map
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl JsFn for NativeFunction {

let keys: Vec<Vec<u8>> = STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();
let stable_b_tree_map = &stable_b_tree_maps[&memory_id];
let stable_b_tree_map = stable_b_tree_maps.get(&memory_id).unwrap();

stable_b_tree_map
.iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl JsFn for NativeFunction {
let len = STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();

stable_b_tree_maps[&memory_id].len()
stable_b_tree_maps.get(&memory_id).unwrap().len()
});

context.new_string(&len.to_string()).into()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl JsFn for NativeFunction {

let values: Vec<Vec<u8>> = STABLE_B_TREE_MAPS.with(|stable_b_tree_maps| {
let stable_b_tree_maps = stable_b_tree_maps.borrow();
let stable_b_tree_map = &stable_b_tree_maps[&memory_id];
let stable_b_tree_map = stable_b_tree_maps.get(&memory_id).unwrap();

stable_b_tree_map
.iter()
Expand Down
Loading