# zig reduce: redesign · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/13964796561a5e6ca16c76020bc3371858decb31)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 13964796561a5e6ca16c76020bc3371858decb31

Requested commit: 13964796561a5e6ca16c76020bc3371858decb31

Commit: 13964796561a5e6ca16c76020bc3371858decb31

Tree: 181663792c456e56d0a5975eee5ac1eff0a7355a

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
zig reduce: redesign

Now it works like this:
1. Walk the AST of the source file looking for independent
   reductions and collecting them all into an array list.
2. Randomize the list of transformations. A future enhancement will add
   priority weights to the sorting but for now they are completely
   shuffled.
3. Apply a subset consisting of 1/2 of the transformations and check for
   interestingness.
4. If not interesting, half the subset size again and check again.
5. Repeat until the subset size is 1, then march the transformation
   index forward by 1 with each non-interesting attempt.

At any point if a subset of transformations succeeds in producing an interesting
result, restart the whole process, reparsing the AST and re-generating the list
of all possible transformations and shuffling it again.

As for std.zig.render, the fixups operate based on AST Node Index rather
than Nth index of the function occurence. This allows precise control
over how to mutate the input.

```

## Parents

- [dff13e088b4da3fab50d72a8967b0d7cffeb9d7d](https://git.cafe/gitcafe/zig/commit/dff13e088b4da3fab50d72a8967b0d7cffeb9d7d?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/13964796561a5e6ca16c76020bc3371858decb31?format=markdown)
