compile special instructions for partial strings when recognized

This commit is contained in:
Mark Thom
2020-04-11 21:53:28 -06:00
parent 92d8642133
commit 6e4b76a3b4
16 changed files with 737 additions and 302 deletions

View File

@@ -179,12 +179,23 @@ impl<T: RawBlockTraits> HeapTemplate<T> {
}
#[inline]
fn pop(&mut self) {
pub(crate)
fn put_complete_string(&mut self, s: &str) -> Addr {
let addr = self.allocate_pstr(s);
self.pop();
let h = self.h();
if h > 0 {
self.truncate(h - 1);
match &mut self[h - 1] {
&mut HeapCellValue::PartialString(_, ref mut has_tail) => {
*has_tail = false;
}
_ => {
unreachable!()
}
}
addr
}
#[inline]
@@ -219,21 +230,7 @@ impl<T: RawBlockTraits> HeapTemplate<T> {
if s.is_empty() {
Addr::EmptyList
} else {
let addr = self.allocate_pstr(&s);
self.pop();
let h = self.h();
match &mut self[h - 1] {
&mut HeapCellValue::PartialString(_, ref mut has_tail) => {
*has_tail = false;
}
_ => {
unreachable!()
}
}
addr
self.put_complete_string(&s)
}
}
Constant::Usize(n) => {
@@ -242,6 +239,16 @@ impl<T: RawBlockTraits> HeapTemplate<T> {
}
}
#[inline]
pub(crate)
fn pop(&mut self) {
let h = self.h();
if h > 0 {
self.truncate(h - 1);
}
}
#[inline]
pub(crate)
fn push(&mut self, val: HeapCellValue) -> usize {