# AstGen: rework multi-object for loop · gitcafe/zig

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

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

Visibility: public

Requested revision: faa44e2e5875036b105d8b7d38ccb2e93757a3c5

Requested commit: faa44e2e5875036b105d8b7d38ccb2e93757a3c5

Commit: faa44e2e5875036b105d8b7d38ccb2e93757a3c5

Tree: fc384ad77143ae6a5c7df5a19da4c2ccfef364d9

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
AstGen: rework multi-object for loop

* Allow unbounded looping.
* Lower by incrementing raw pointers for each iterable rather than
  incrementing a single index variable. This elides safety checks
  without any analysis required thanks to the length assertion and
  lowers to decent machine code even in debug builds.
  - An "end" value is selected, prioritizing a counter if possible,
    falling back to a runtime calculation of ptr+len on a slice input.
* Specialize on the pattern `0..`, avoiding an unnecessary subtraction
  instruction being emitted.
* Add the `for_check_lens` ZIR instruction.

```

## Parents

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

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