remove some uncessary allocations/copies
This commit is contained in:
@@ -1328,9 +1328,7 @@ impl Indexer for DynamicCodeIndices {
|
|||||||
for (key, code) in indices.into_iter() {
|
for (key, code) in indices.into_iter() {
|
||||||
if code.len() > 1 {
|
if code.len() > 1 {
|
||||||
index_locs.insert(key, IndexingCodePtr::Internal(prelude.len() + 1));
|
index_locs.insert(key, IndexingCodePtr::Internal(prelude.len() + 1));
|
||||||
prelude.push_back(IndexingLine::DynamicIndexedChoice(
|
prelude.push_back(IndexingLine::DynamicIndexedChoice(code));
|
||||||
code.into_iter().collect(),
|
|
||||||
));
|
|
||||||
} else if let Some(i) = code.front() {
|
} else if let Some(i) = code.front() {
|
||||||
index_locs.insert(key, IndexingCodePtr::DynamicExternal(*i));
|
index_locs.insert(key, IndexingCodePtr::DynamicExternal(*i));
|
||||||
}
|
}
|
||||||
@@ -1369,9 +1367,7 @@ impl Indexer for DynamicCodeIndices {
|
|||||||
) -> IndexingCodePtr {
|
) -> IndexingCodePtr {
|
||||||
if lists.len() > 1 {
|
if lists.len() > 1 {
|
||||||
let lists = std::mem::take(lists);
|
let lists = std::mem::take(lists);
|
||||||
prelude.push_back(IndexingLine::DynamicIndexedChoice(
|
prelude.push_back(IndexingLine::DynamicIndexedChoice(lists));
|
||||||
lists.into_iter().collect(),
|
|
||||||
));
|
|
||||||
IndexingCodePtr::Internal(1)
|
IndexingCodePtr::Internal(1)
|
||||||
} else {
|
} else {
|
||||||
lists
|
lists
|
||||||
@@ -1548,6 +1544,6 @@ impl<I: Indexer> CodeOffsets<I> {
|
|||||||
str_loc,
|
str_loc,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
prelude.into_iter().collect()
|
prelude.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::collections::BTreeSet;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -8,9 +7,8 @@ pub struct MachineArgs {
|
|||||||
|
|
||||||
impl MachineArgs {
|
impl MachineArgs {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let args: BTreeSet<String> = env::args().collect();
|
|
||||||
Self {
|
Self {
|
||||||
add_history: !args.contains("--no-add-history"),
|
add_history: env::args().all(|arg| arg != "--no-add-history"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,14 +224,14 @@ impl Term {
|
|||||||
|
|
||||||
let list = match tail {
|
let list = match tail {
|
||||||
Term::Atom(atom) if atom == "[]" => match head {
|
Term::Atom(atom) if atom == "[]" => match head {
|
||||||
Term::Atom(ref a) if a.chars().collect::<Vec<_>>().len() == 1 => {
|
Term::Atom(ref a) if a.chars().count() == 1 => {
|
||||||
// Handle lists of char as strings
|
// Handle lists of char as strings
|
||||||
Term::String(a.to_string())
|
Term::String(a.to_string())
|
||||||
}
|
}
|
||||||
_ => Term::List(vec![head]),
|
_ => Term::List(vec![head]),
|
||||||
},
|
},
|
||||||
Term::List(elems) if elems.is_empty() => match head {
|
Term::List(elems) if elems.is_empty() => match head {
|
||||||
Term::Atom(ref a) if a.chars().collect::<Vec<_>>().len() == 1 => {
|
Term::Atom(ref a) if a.chars().count() == 1 => {
|
||||||
// Handle lists of char as strings
|
// Handle lists of char as strings
|
||||||
Term::String(a.to_string())
|
Term::String(a.to_string())
|
||||||
},
|
},
|
||||||
@@ -242,7 +242,7 @@ impl Term {
|
|||||||
Term::List(elems)
|
Term::List(elems)
|
||||||
},
|
},
|
||||||
Term::String(mut elems) => match head {
|
Term::String(mut elems) => match head {
|
||||||
Term::Atom(ref a) if a.chars().collect::<Vec<_>>().len() == 1 => {
|
Term::Atom(ref a) if a.chars().count() == 1 => {
|
||||||
// Handle lists of char as strings
|
// Handle lists of char as strings
|
||||||
elems.insert(0, a.chars().next().unwrap());
|
elems.insert(0, a.chars().next().unwrap());
|
||||||
Term::String(elems)
|
Term::String(elems)
|
||||||
|
|||||||
@@ -1842,9 +1842,7 @@ impl Machine {
|
|||||||
let err = self.machine_st.permission_error(
|
let err = self.machine_st.permission_error(
|
||||||
Permission::Modify,
|
Permission::Modify,
|
||||||
atom!("static_procedure"),
|
atom!("static_procedure"),
|
||||||
functor_stub(atom!(":"), 2)
|
functor_stub(atom!(":"), 2),
|
||||||
.into_iter()
|
|
||||||
.collect::<MachineStub>(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
self.machine_st
|
self.machine_st
|
||||||
|
|||||||
Reference in New Issue
Block a user