From ae3019d9230d12beedeffb08f817b05db7420086 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bennet=20Ble=C3=9Fmann?= Date: Thu, 31 Jul 2025 21:31:34 +0200 Subject: [PATCH] fix unecessary reference/dereference --- src/atom_table.rs | 2 +- src/forms.rs | 6 +++--- src/iterators.rs | 2 +- src/machine/dispatch.rs | 2 +- src/machine/heap.rs | 2 +- src/machine/system_calls.rs | 8 ++++---- src/machine/unify.rs | 2 +- src/parser/ast.rs | 6 +++--- src/parser/parser.rs | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/atom_table.rs b/src/atom_table.rs index 12910753..d7796d73 100644 --- a/src/atom_table.rs +++ b/src/atom_table.rs @@ -254,7 +254,7 @@ impl std::ops::Deref for AtomString<'_> { fn deref(&self) -> &Self::Target { match self { Self::Static(reference) => reference, - Self::Inlined(inlined) => inlined_to_str(&inlined), + Self::Inlined(inlined) => inlined_to_str(inlined), Self::Dynamic(guard) => guard.deref(), } } diff --git a/src/forms.rs b/src/forms.rs index 409da51e..26f37b3e 100644 --- a/src/forms.rs +++ b/src/forms.rs @@ -372,11 +372,11 @@ pub enum ModuleSource { impl ModuleSource { pub(crate) fn as_functor_stub(&self) -> MachineStub { - match self { - &ModuleSource::Library(name) => { + match *self { + ModuleSource::Library(name) => { functor!(atom!("library"), [atom_as_cell(name)]) } - &ModuleSource::File(name) => { + ModuleSource::File(name) => { functor!(name) } } diff --git a/src/iterators.rs b/src/iterators.rs index 5bd51d99..8e2e43dd 100644 --- a/src/iterators.rs +++ b/src/iterators.rs @@ -403,7 +403,7 @@ impl<'a> Iterator for ClauseIterator<'a> { self.state_stack .push(ClauseIteratorState::RemainingBranches(branches, 0)); } - &ChunkedTerms::Chunk { ref terms } => { + ChunkedTerms::Chunk { ref terms } => { return Some(ClauseItem::Chunk { terms }); } } diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index 2428f7d2..af34bcd7 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -3277,7 +3277,7 @@ impl Machine { &Instruction::PutPartialString(_, ref string, reg) => { self.machine_st[reg] = backtrack_on_resource_error!( self.machine_st, - self.machine_st.heap.allocate_pstr(&string) + self.machine_st.heap.allocate_pstr(string) ); self.machine_st.p += 1; diff --git a/src/machine/heap.rs b/src/machine/heap.rs index fdf24047..66e511f5 100644 --- a/src/machine/heap.rs +++ b/src/machine/heap.rs @@ -1009,7 +1009,7 @@ impl<'a> PStrSegmentIter<'a> { let string_buf = unsafe { let char_ptr = heap.inner.ptr.add(pstr_loc); let slice = std::slice::from_raw_parts(char_ptr, heap.inner.byte_len - pstr_loc); - std::str::from_utf8_unchecked(&slice) + std::str::from_utf8_unchecked(slice) }; PStrSegmentIter { string_buf } diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 244d56af..ac09b7f8 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -2327,7 +2327,7 @@ impl Machine { let cell = step_or_resource_error!( self.machine_st, - self.machine_st.heap.allocate_cstr(&*name.as_str()) + self.machine_st.heap.allocate_cstr(&name.as_str()) ); unify!(self.machine_st, self.machine_st.registers[2], cell); @@ -2386,7 +2386,7 @@ impl Machine { self.machine_st, sized_iter_to_heap_list( &mut self.machine_st.heap, - (&*name).chars().count(), + name.chars().count(), iter, ) ); @@ -7637,7 +7637,7 @@ impl Machine { let buffer = git_version!(cargo_prefix = "cargo:", fallback = "unknown"); let cstr_cell = - step_or_resource_error!(self.machine_st, self.machine_st.heap.allocate_cstr(&buffer)); + step_or_resource_error!(self.machine_st, self.machine_st.heap.allocate_cstr(buffer)); unify!(self.machine_st, cstr_cell, self.machine_st.registers[1]); } @@ -8719,7 +8719,7 @@ impl Machine { Ok(result) } scraper::Node::Comment(comment) => { - let comment = self.machine_st.heap.allocate_cstr(&comment)?; + let comment = self.machine_st.heap.allocate_cstr(comment)?; let result = str_loc_as_cell!(self.machine_st.heap.cell_len()); let mut writer = self.machine_st.heap.reserve(2)?; diff --git a/src/machine/unify.rs b/src/machine/unify.rs index 6ada6fb1..fdc430ee 100644 --- a/src/machine/unify.rs +++ b/src/machine/unify.rs @@ -290,7 +290,7 @@ pub(crate) trait Unifier: DerefMut { let machine_st = self.deref_mut(); let f1 = machine_st.arena.f64_tbl.get_entry(f1); - let f2 = machine_st.arena.f64_tbl.get_entry(f2.into()); + let f2 = machine_st.arena.f64_tbl.get_entry(f2); self.fail = f1 != f2; } diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 654b2901..da9353ec 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -858,9 +858,9 @@ impl Term { } pub fn name(&self) -> Option { - match self { - &Term::Literal(_, Literal::Atom(atom)) => Some(atom), - &Term::Clause(_, atom, ..) => Some(atom), + match *self { + Term::Literal(_, Literal::Atom(atom)) => Some(atom), + Term::Clause(_, atom, ..) => Some(atom), _ => None, } } diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 7a889520..a874face 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -111,7 +111,7 @@ pub(crate) fn as_partial_string( tail_ref = tail; } Term::CompleteString(_, cstr) => { - string += &*cstr.as_str(); + string += cstr.as_str(); tail = Term::Literal(Cell::default(), Literal::Atom(atom!("[]"))); break; } -- 2.54.0