fix unecessary reference/dereference
This commit is contained in:
committed by
Bennet Bleßmann
parent
72631b3e0b
commit
ae3019d923
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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)?;
|
||||
|
||||
@@ -290,7 +290,7 @@ pub(crate) trait Unifier: DerefMut<Target = MachineState> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -858,9 +858,9 @@ impl Term {
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<Atom> {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user