nixpulvis / brainfuck

A simple brainfuck interpreter in Rust.
http://nixpulvis.com/brainfuck
23 stars 3 forks source link

Make SkipForward and SkipBackword Constant Running Time #6

Closed nixpulvis closed 8 years ago

nixpulvis commented 8 years ago

Currently the implementations of both [ and ] require a lookup through the code to find the matching brace each time. This should be avoided by doing some analysis up front (when the code is first loaded). This is also the reason for new #5 returning a Result because the code could be invalid when there are unmatched brackets.