Skip to content
Closed
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
2 changes: 1 addition & 1 deletion Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ authors = [""]
compiler_version = ">=0.36.0"

[dependencies]
sort = { tag = "v0.2.3", git = "https://github.com/noir-lang/noir_sort" }
sort = { tag = "v0.3.0", git = "https://github.com/noir-lang/noir_sort" }
6 changes: 3 additions & 3 deletions src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ where
// case 2 can be modified to `self.keys[found_index] + 1 <= idx <= self.keys[found_index + 1] - 1
// combine the two into the following single statement:
// `self.keys[found_index] + 1 - found <= idx <= self.keys[found_index + 1 - found] - 1 + found
let lhs = self.keys[found_index];
let rhs = self.keys[found_index + 1 - found];
let lhs = self.keys[found_index as u32];
let rhs = self.keys[(found_index + 1 - found) as u32];
let lhs_condition = idx - lhs - 1 + found;
let rhs_condition = rhs - 1 + found - idx;
lhs_condition.assert_max_bit_size::<32>();
Expand All @@ -161,7 +161,7 @@ where
// self.keys[i] maps to self.values[i+1]
// however...if we did not find a non-sparse entry, we want to return self.values[0] (the default value)
let value_index = (found_index + 1) * found;
self.values[value_index]
self.values[value_index as u32]
}
}

Expand Down
24 changes: 12 additions & 12 deletions src/mut_sparse_array.nr
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ where
unsafe { self.__check_if_can_insert(found) };

let lhs_index = found_index;
let rhs_index = self.linked_keys[found_index];
let rhs_index = self.linked_keys[found_index as u32];

assert(found * found == found);

Expand All @@ -181,8 +181,8 @@ where
// case 2 can be modified to `self.keys[found_index] + 1 <= idx <= self.keys[found_index + 1] - 1
// combine the two into the following single statement:
// `self.keys[found_index] + 1 - found <= idx <= self.keys[found_index + 1 - found] - 1 + found
let lhs = self.keys[lhs_index];
let rhs = self.keys[rhs_index];
let lhs = self.keys[lhs_index as u32];
let rhs = self.keys[rhs_index as u32];
let lhs_condition = idx - lhs - 1 + found;
let rhs_condition = rhs - 1 + found - idx;
ComparisonFuncs::assert_greater_than_or_equal(lhs_condition, 0);
Expand All @@ -193,15 +193,15 @@ where
// lhs points to tail_ptr
// tail_ptr points to rhs
if (found == 0) {
self.keys[self.tail_ptr] = idx;
self.keys[self.tail_ptr as u32] = idx;

self.linked_keys[found_index] = self.tail_ptr * (1 - found) + found * rhs_index;
self.linked_keys[found_index as u32] = self.tail_ptr * (1 - found) + found * rhs_index;

self.linked_keys[self.tail_ptr] = rhs_index * (1 - found);
self.values[self.tail_ptr + 1] = value;
self.linked_keys[self.tail_ptr as u32] = rhs_index * (1 - found);
self.values[(self.tail_ptr + 1) as u32] = value;
self.tail_ptr += 1;
} else {
self.values[found_index + 1] = value;
self.values[(found_index + 1) as u32] = value;
}
}

Expand All @@ -211,7 +211,7 @@ where
assert(found * found == found);

let lhs_index = found_index;
let rhs_index = self.linked_keys[found_index];
let rhs_index = self.linked_keys[found_index as u32];

assert(found * found == found);

Expand All @@ -223,8 +223,8 @@ where
// case 2 can be modified to `self.keys[found_index] + 1 <= idx <= self.keys[found_index + 1] - 1
// combine the two into the following single statement:
// `self.keys[found_index] + 1 - found <= idx <= self.keys[found_index + 1 - found] - 1 + found
let lhs = self.keys[lhs_index];
let rhs = self.keys[rhs_index];
let lhs = self.keys[lhs_index as u32];
let rhs = self.keys[rhs_index as u32];
let lhs_condition = idx - lhs - 1 + found;
let rhs_condition = rhs - 1 + found - idx;
ComparisonFuncs::assert_greater_than_or_equal(lhs_condition, 0);
Expand All @@ -233,7 +233,7 @@ where
// lhs_condition.assert_max_bit_size::<32>();
// rhs_condition.assert_max_bit_size::<32>();
let value_index = (lhs_index + 1) * found;
self.values[value_index]
self.values[value_index as u32]
}
}

Expand Down