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

chore: convert vec references to slices #4133

Merged
merged 2 commits into from
Jan 23, 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
6 changes: 3 additions & 3 deletions acvm-repo/brillig_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
self.registers.set(register_index, value);
}

pub fn get_memory(&self) -> &Vec<Value> {
pub fn get_memory(&self) -> &[Value] {
self.memory.values()
}

Expand Down Expand Up @@ -552,7 +552,7 @@
}

#[test]
fn jmpifnot_opcode() {

Check warning on line 555 in acvm-repo/brillig_vm/src/lib.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (jmpifnot)
let input_registers =
Registers::load(vec![Value::from(1u128), Value::from(2u128), Value::from(0u128)]);

Expand Down Expand Up @@ -748,7 +748,7 @@

let opcodes = [&start[..], &loop_body[..]].concat();
let vm = brillig_execute_and_get_vm(memory, &opcodes);
vm.get_memory().clone()
vm.get_memory().to_vec()
}

let memory = brillig_write_memory(vec![Value::from(0u128); 5]);
Expand Down Expand Up @@ -904,7 +904,7 @@

let opcodes = [&start[..], &recursive_fn[..]].concat();
let vm = brillig_execute_and_get_vm(memory, &opcodes);
vm.get_memory().clone()
vm.get_memory().to_vec()
}

let memory = brillig_recursive_write_memory(vec![Value::from(0u128); 5]);
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/brillig_vm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Memory {
}

/// Returns the values of the memory
pub fn values(&self) -> &Vec<Value> {
pub fn values(&self) -> &[Value] {
&self.inner
}
}
2 changes: 1 addition & 1 deletion compiler/noirc_driver/src/abi_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn into_abi_params(context: &Context, params: Vec<Param>) -> Vec<AbiParameter> {
// Takes each abi parameter and shallowly maps to the expected witness range in which the
// parameter's constituent values live.
fn param_witnesses_from_abi_param(
abi_params: &Vec<AbiParameter>,
abi_params: &[AbiParameter],
input_witnesses: Vec<Witness>,
) -> BTreeMap<String, Vec<Range<Witness>>> {
let mut idx = 0_usize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ fn execute_brillig(
// It may be finished, in-progress, failed, or may be waiting for results of a foreign call.
// If it's finished then we can omit the opcode and just write in the return values.
match vm_status {
VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().clone())),
VMStatus::Finished => Some((vm.get_registers().clone(), vm.get_memory().to_vec())),
VMStatus::InProgress => unreachable!("Brillig VM has not completed execution"),
VMStatus::Failure { .. } => {
// TODO: Return an error stating that the brillig function failed.
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/ast/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl NoirFunction {
pub fn function_attribute(&self) -> Option<&FunctionAttribute> {
self.def.attributes.function.as_ref()
}
pub fn secondary_attributes(&self) -> &Vec<SecondaryAttribute> {
pub fn secondary_attributes(&self) -> &[SecondaryAttribute] {
self.def.attributes.secondary.as_ref()
}
pub fn def(&self) -> &FunctionDefinition {
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,11 @@
.collect()
}

// TODO(vitkov): Move this out of here and into type_check

Check warning on line 459 in compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (vitkov)
#[allow(clippy::too_many_arguments)]
pub(crate) fn check_methods_signatures(
resolver: &mut Resolver,
impl_methods: &Vec<(FileId, FuncId)>,
impl_methods: &[(FileId, FuncId)],
trait_id: TraitId,
trait_name_span: Span,
// These are the generics on the trait itself from the impl.
Expand Down
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,9 +1028,9 @@ impl<'interner> TypeChecker<'interner> {

fn bind_function_type_impl(
&mut self,
fn_params: &Vec<Type>,
fn_params: &[Type],
fn_ret: &Type,
callsite_args: &Vec<(Type, ExprId, Span)>,
callsite_args: &[(Type, ExprId, Span)],
span: Span,
) -> Type {
if fn_params.len() != callsite_args.len() {
Expand Down
4 changes: 2 additions & 2 deletions tooling/nargo/src/ops/foreign_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ impl MockedCall {
}

impl MockedCall {
fn matches(&self, name: &str, params: &Vec<ForeignCallParam>) -> bool {
self.name == name && (self.params.is_none() || self.params.as_ref() == Some(params))
fn matches(&self, name: &str, params: &[ForeignCallParam]) -> bool {
self.name == name && (self.params.is_none() || self.params.as_deref() == Some(params))
}
}

Expand Down