Reduce Statement
memory footprint
This commit is contained in:
parent
170c5c3629
commit
460363bff1
@ -57,7 +57,7 @@ impl From<BlockData> for LabelType {
|
||||
struct StatList {
|
||||
stack: Stack,
|
||||
code: Vec<Statement>,
|
||||
last: Option<Terminator>,
|
||||
last: Option<Box<Terminator>>,
|
||||
|
||||
block_data: BlockData,
|
||||
has_reference: bool,
|
||||
@ -199,7 +199,7 @@ impl StatList {
|
||||
|
||||
fn set_terminator(&mut self, term: Terminator) {
|
||||
self.leak_all();
|
||||
self.last = Some(term);
|
||||
self.last = Some(term.into());
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,15 +310,13 @@ impl<'a> Factory<'a> {
|
||||
BlockData::Forward { .. } | BlockData::Backward { .. } => Statement::Block(now.into()),
|
||||
BlockData::If { .. } => Statement::If(If {
|
||||
condition: self.target.stack.pop().into(),
|
||||
on_true: now.into(),
|
||||
on_true: Box::new(now.into()),
|
||||
on_false: None,
|
||||
}),
|
||||
BlockData::Else { .. } => {
|
||||
if let Statement::If(v) = self.target.code.last_mut().unwrap() {
|
||||
v.on_false = Some(now.into());
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
let Statement::If(last) = self.target.code.last_mut().unwrap() else { unreachable!() };
|
||||
|
||||
last.on_false = Some(Box::new(now.into()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -887,7 +887,7 @@ pub enum Terminator {
|
||||
pub struct Block {
|
||||
pub(crate) label_type: Option<LabelType>,
|
||||
pub(crate) code: Vec<Statement>,
|
||||
pub(crate) last: Option<Terminator>,
|
||||
pub(crate) last: Option<Box<Terminator>>,
|
||||
}
|
||||
|
||||
impl Block {
|
||||
@ -902,8 +902,8 @@ impl Block {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn last(&self) -> Option<&Terminator> {
|
||||
self.last.as_ref()
|
||||
pub fn last(&self) -> Option<&Terminator> {
|
||||
self.last.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
@ -926,8 +926,8 @@ impl BrIf {
|
||||
|
||||
pub struct If {
|
||||
pub(crate) condition: Box<Expression>,
|
||||
pub(crate) on_true: Block,
|
||||
pub(crate) on_false: Option<Block>,
|
||||
pub(crate) on_true: Box<Block>,
|
||||
pub(crate) on_false: Option<Box<Block>>,
|
||||
}
|
||||
|
||||
impl If {
|
||||
@ -937,13 +937,13 @@ impl If {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn on_true(&self) -> &Block {
|
||||
pub fn on_true(&self) -> &Block {
|
||||
&self.on_true
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn on_false(&self) -> Option<&Block> {
|
||||
self.on_false.as_ref()
|
||||
pub fn on_false(&self) -> Option<&Block> {
|
||||
self.on_false.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user