fix unecessary reference/dereference

This commit is contained in:
Bennet Bleßmann
2025-07-31 21:31:34 +02:00
committed by Bennet Bleßmann
parent 72631b3e0b
commit ae3019d923
9 changed files with 16 additions and 16 deletions

View File

@@ -254,7 +254,7 @@ impl std::ops::Deref for AtomString<'_> {
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
match self { match self {
Self::Static(reference) => reference, Self::Static(reference) => reference,
Self::Inlined(inlined) => inlined_to_str(&inlined), Self::Inlined(inlined) => inlined_to_str(inlined),
Self::Dynamic(guard) => guard.deref(), Self::Dynamic(guard) => guard.deref(),
} }
} }

View File

@@ -372,11 +372,11 @@ pub enum ModuleSource {
impl ModuleSource { impl ModuleSource {
pub(crate) fn as_functor_stub(&self) -> MachineStub { pub(crate) fn as_functor_stub(&self) -> MachineStub {
match self { match *self {
&ModuleSource::Library(name) => { ModuleSource::Library(name) => {
functor!(atom!("library"), [atom_as_cell(name)]) functor!(atom!("library"), [atom_as_cell(name)])
} }
&ModuleSource::File(name) => { ModuleSource::File(name) => {
functor!(name) functor!(name)
} }
} }

View File

@@ -403,7 +403,7 @@ impl<'a> Iterator for ClauseIterator<'a> {
self.state_stack self.state_stack
.push(ClauseIteratorState::RemainingBranches(branches, 0)); .push(ClauseIteratorState::RemainingBranches(branches, 0));
} }
&ChunkedTerms::Chunk { ref terms } => { ChunkedTerms::Chunk { ref terms } => {
return Some(ClauseItem::Chunk { terms }); return Some(ClauseItem::Chunk { terms });
} }
} }

View File

@@ -3277,7 +3277,7 @@ impl Machine {
&Instruction::PutPartialString(_, ref string, reg) => { &Instruction::PutPartialString(_, ref string, reg) => {
self.machine_st[reg] = backtrack_on_resource_error!( self.machine_st[reg] = backtrack_on_resource_error!(
self.machine_st, self.machine_st,
self.machine_st.heap.allocate_pstr(&string) self.machine_st.heap.allocate_pstr(string)
); );
self.machine_st.p += 1; self.machine_st.p += 1;

View File

@@ -1009,7 +1009,7 @@ impl<'a> PStrSegmentIter<'a> {
let string_buf = unsafe { let string_buf = unsafe {
let char_ptr = heap.inner.ptr.add(pstr_loc); let char_ptr = heap.inner.ptr.add(pstr_loc);
let slice = std::slice::from_raw_parts(char_ptr, heap.inner.byte_len - 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 } PStrSegmentIter { string_buf }

View File

@@ -2327,7 +2327,7 @@ impl Machine {
let cell = step_or_resource_error!( let cell = step_or_resource_error!(
self.machine_st, 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); unify!(self.machine_st, self.machine_st.registers[2], cell);
@@ -2386,7 +2386,7 @@ impl Machine {
self.machine_st, self.machine_st,
sized_iter_to_heap_list( sized_iter_to_heap_list(
&mut self.machine_st.heap, &mut self.machine_st.heap,
(&*name).chars().count(), name.chars().count(),
iter, iter,
) )
); );
@@ -7637,7 +7637,7 @@ impl Machine {
let buffer = git_version!(cargo_prefix = "cargo:", fallback = "unknown"); let buffer = git_version!(cargo_prefix = "cargo:", fallback = "unknown");
let cstr_cell = 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]); unify!(self.machine_st, cstr_cell, self.machine_st.registers[1]);
} }
@@ -8719,7 +8719,7 @@ impl Machine {
Ok(result) Ok(result)
} }
scraper::Node::Comment(comment) => { 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 result = str_loc_as_cell!(self.machine_st.heap.cell_len());
let mut writer = self.machine_st.heap.reserve(2)?; let mut writer = self.machine_st.heap.reserve(2)?;

View File

@@ -290,7 +290,7 @@ pub(crate) trait Unifier: DerefMut<Target = MachineState> {
let machine_st = self.deref_mut(); let machine_st = self.deref_mut();
let f1 = machine_st.arena.f64_tbl.get_entry(f1); 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; self.fail = f1 != f2;
} }

View File

@@ -858,9 +858,9 @@ impl Term {
} }
pub fn name(&self) -> Option<Atom> { pub fn name(&self) -> Option<Atom> {
match self { match *self {
&Term::Literal(_, Literal::Atom(atom)) => Some(atom), Term::Literal(_, Literal::Atom(atom)) => Some(atom),
&Term::Clause(_, atom, ..) => Some(atom), Term::Clause(_, atom, ..) => Some(atom),
_ => None, _ => None,
} }
} }

View File

@@ -111,7 +111,7 @@ pub(crate) fn as_partial_string(
tail_ref = tail; tail_ref = tail;
} }
Term::CompleteString(_, cstr) => { Term::CompleteString(_, cstr) => {
string += &*cstr.as_str(); string += cstr.as_str();
tail = Term::Literal(Cell::default(), Literal::Atom(atom!("[]"))); tail = Term::Literal(Cell::default(), Literal::Atom(atom!("[]")));
break; break;
} }