Skip to content

Commit

Permalink
fix(performance): Remove redundant slice access check from brillig (#…
Browse files Browse the repository at this point in the history
…7434)

Co-authored-by: Tom French <tom@tomfren.ch>
  • Loading branch information
vezenovm and TomAFrench authored Feb 18, 2025
1 parent 988adae commit 49a095d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,10 @@ impl<'block, Registers: RegisterAllocator> BrilligBlock<'block, Registers> {

let index_variable = self.convert_ssa_single_addr_value(*index, dfg);

if !dfg.is_safe_index(*index, *array) {
// Slice access checks are generated separately against the slice's dynamic length field.
if matches!(dfg.type_of_value(*array), Type::Array(..))
&& !dfg.is_safe_index(*index, *array)
{
self.validate_array_index(array_variable, index_variable);
}

Expand Down Expand Up @@ -795,7 +798,10 @@ impl<'block, Registers: RegisterAllocator> BrilligBlock<'block, Registers> {
dfg,
);

if !dfg.is_safe_index(*index, *array) {
// Slice access checks are generated separately against the slice's dynamic length field.
if matches!(dfg.type_of_value(*array), Type::Array(..))
&& !dfg.is_safe_index(*index, *array)
{
self.validate_array_index(source_variable, index_register);
}

Expand Down

0 comments on commit 49a095d

Please sign in to comment.