Skip to content

Commit

Permalink
Remove unused special-case for constant outputs (#160)
Browse files Browse the repository at this point in the history
This isn't needed anymore; it's handled earlier in the function.
  • Loading branch information
mkeeter authored Aug 27, 2024
1 parent 964a9ab commit 932685d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fidget/src/core/compiler/ssa_tape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,6 @@ impl SsaTape {
tape.push(op);
}

// Special case if the Node is a single constant, which isn't usually
// recorded in the tape
if tape.is_empty() {
let c = ctx.get_const(root).unwrap() as f32;
tape.push(SsaOp::CopyImm(0, c));
}
Ok((SsaTape { tape, choice_count }, vars))
}

Expand Down Expand Up @@ -431,4 +425,13 @@ mod test {
assert_eq!(tape.len(), 3); // x, square, output
assert_eq!(vs.len(), 1);
}

#[test]
fn test_constant() {
let mut ctx = Context::new();
let p = ctx.constant(1.5);
let (tape, vs) = SsaTape::new(&ctx, p).unwrap();
assert_eq!(tape.len(), 2); // CopyImm, output
assert_eq!(vs.len(), 0);
}
}

0 comments on commit 932685d

Please sign in to comment.