Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range checks for bf tests #473

Open
nuald opened this issue Oct 18, 2023 · 1 comment
Open

Add range checks for bf tests #473

nuald opened this issue Oct 18, 2023 · 1 comment

Comments

@nuald
Copy link
Collaborator

nuald commented Oct 18, 2023

The original implementation (the mirror in https://gitlab.com/nuald-grp/bf-2) has the range check and properly handles the out of bound access. Some of the existing tests don't have it, thus may have the unfair advantage because of it.

nuald referenced this issue Oct 18, 2023
* Update the Rust's brainfuck implementation

More idiomatic code, and formatting with `rustfmt`. The most important change was in the `Tape` impl:

* `mov()` reallocs only once per call;
* `get()` and `inc()` uses unchecked indexing because the check is already done in `mov()`

* Pass String as reference

* Use more specific enum variants

Because of the strong typing, the `mov()` was doing many lossy
casts which the C and C++ versions don't; the D version uses
specific variants too.

Besides, the value was always -1 or 1, so it is more idiomatic
this way.
@ricvelozo
Copy link
Contributor

Related: #290.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants