Commit 6fae4d3
Convert while loops into for loops
I used a very powerful tool [coccinelle](https://gitlab.inria.fr/coccinelle/coccinelleforrust) (its C version is used for Linux kernel refactorings). Highly recommend installing it as it has a potential to simplify refactorings while not dealing with regex errors.
To install it, run
```sh
cargo install --git https://gitlab.inria.fr/coccinelle/coccinelleforrust
```
Afterward, create this file as `target/repl2.cocci` with the following content. Using `target/` ensures that it will be ignored by git.
```diff
@@
expression i, end;
@@
-i = 0usize;
-while i < end
+for i in 0usize..end
-{
{
...
}
- i = i.wrapping_add(1);
-}
```
and run this command from the root of the repo:
```shell
cfr -c target/repl2.cocci src/ --apply
cargo fmt --all
```
Afterwards, I compiled and removed all unused index variables.1 parent b42042b commit 6fae4d3
File tree
14 files changed
+828
-1266
lines changed- src/enc
- backward_references
14 files changed
+828
-1266
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 294 | + | |
| 295 | + | |
300 | 296 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
311 | 304 | | |
312 | | - | |
313 | 305 | | |
| 306 | + | |
314 | 307 | | |
315 | | - | |
316 | 308 | | |
317 | 309 | | |
318 | 310 | | |
| |||
0 commit comments