~tmpod/toasty-lc3-vm

Remove small optimization when parsing the input instruction. Any instructions following INP were being ignored. v1 PROPOSED

jpl: 1
 Remove small optimization when parsing the input instruction. Any instructions following INP were being ignored.

 1 files changed, 4 insertions(+), 4 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~tmpod/toasty-lc3-vm/patches/34358/mbox | git am -3
Learn more about email & git

[PATCH] Remove small optimization when parsing the input instruction. Any instructions following INP were being ignored. Export this patch

---
 src/ir.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/ir.rs b/src/ir.rs
index 4ae3518..3ee6ad8 100644
--- a/src/ir.rs
+++ b/src/ir.rs
@@ -57,10 +57,10 @@ impl BrainfuckIR {
                }
            };

            // Tiny optimization I suppose
            if let Some(BrainfuckInstruction::INP) = instructions.last() {
                continue;
            }
            // // Tiny optimization I suppose
            // if let Some(BrainfuckInstruction::INP) = instructions.last() {
            //     continue;
            // }

            instructions.push(inst);
        }
-- 
2.37.1

Not quite sure what the optimization was meant to be, but this blocked any further
instructions from being parsed.
Well, that's embarassing .-.
The idea was to drop multiple successive input instructions (",") as they
serve no purpose and are effectively "expensive" calls. Since you're
not moving the cell pointer inbetween inputs, you're just overwriting the
same thing.
Now that I think more about it though, you *may* want to really have
consecutive input calls, seeing as they block and may be useful in some
circumstances.
I suppose it's better to just drop that altogether; just delete it.