Skip to content

Flatten in linear time - #141

Merged
GrahamCampbell merged 1 commit into
2.11from
flatten-in-linear-time
Nov 29, 2026
Merged

GrahamCampbell merged 1 commit into
2.11from
flatten-in-linear-time

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Collaborator

Flatten merged each inner list into the result with its own array_merge() call, copying everything gathered so far each time, so the work grew with the square of the input: 64,000 two-element lists took about ten seconds. Both runtimes now gather the lists and merge them once, which takes 20 milliseconds for the same input and gives the same result.

@GrahamCampbell
GrahamCampbell marked this pull request as ready for review November 29, 2026 17:31
@GrahamCampbell
GrahamCampbell merged commit dfca232 into 2.11 Nov 29, 2026
44 checks passed
@GrahamCampbell
GrahamCampbell deleted the flatten-in-linear-time branch November 29, 2026 17:31
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