# zig-reduce: Reduce \`if\` expressions · gitcafe/zig

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

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

Visibility: public

Requested revision: 91570cc42d4fe973d15ac05cdecff42051f154ad

Requested commit: 91570cc42d4fe973d15ac05cdecff42051f154ad

Commit: 91570cc42d4fe973d15ac05cdecff42051f154ad

Tree: 933200ee149c2557d3739ed7332e59b4e7ca341e

Author: Adam Goertz

Committer: Adam Goertz

## Message

```
zig-reduce: Reduce `if` expressions

Perform these transformations in this priority order:
1. If the `else` expression is missing or an empty block, replace the condition with `if (true)` if it is not already.
2. If the `then` block is empty, replace the condition with `if (false)` if it is not already.
3. If the condition is `if (true)`, replace the `if` expression with the contents of the `then` expression.
4. If the condition is `if (false)`, replace the `if` expression with the contents of the `else` expression.

```

## Parents

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

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