Skip to content

Treat iterator collect lengths as hints#9805

Open
eluvane wants to merge 3 commits into
roc-lang:mainfrom
eluvane:codeo/collect-size-hint-safe
Open

Treat iterator collect lengths as hints#9805
eluvane wants to merge 3 commits into
roc-lang:mainfrom
eluvane:codeo/collect-size-hint-safe

Conversation

@eluvane

@eluvane eluvane commented Jun 25, 2026

Copy link
Copy Markdown

This PR treats iterator size hints as allocation hints when collecting into lists.

The Iter and Stream collect paths still reserve from Known(n) up front, but they now append through the reserving List.append path. Iter.custom also stops decrementing a depleted Known hint after an over-producing custom iterator yields again, so a too-small user-supplied hint degrades to Unknown instead of crashing.

A regression test builds a custom iterator that reports Known(8) while yielding nine items and checks that Iter.collect returns the full list. The collect worker shape test was updated for the simpler single-append loop.

The hot-reload descriptor test helper now uses the descriptor write path, so descriptor memory is committed before writes on Windows.

@eluvane eluvane marked this pull request as ready for review June 25, 2026 04:04
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

Successfully merging this pull request may close these issues.

1 participant