Skip to content

Make Enum.slide match the semantics of Enum.slice and reduce traversals of the list - #16157

Merged
josevalim merged 4 commits into
elixir-lang:mainfrom
MikaelFangel:push-pykoqymmnlpn
Nov 20, 2026
Merged

josevalim merged 4 commits into
elixir-lang:mainfrom
MikaelFangel:push-pykoqymmnlpn

Conversation

@MikaelFangel

Copy link
Copy Markdown
Contributor

Fixes #16156

Changes

  • Bounds the insertion_index to 0 to avoid retraversing the list linear to the index
  • Making the semantics of Enum.slide match the behavior of Enum.slice

This PR is linked to the issues outlined in the issue I just submitted.

@josevalim
josevalim merged commit a706bbe into elixir-lang:main Nov 20, 2026
15 checks passed
@MikaelFangel
MikaelFangel deleted the push-pykoqymmnlpn branch November 20, 2026 10:45
@MikaelFangel

Copy link
Copy Markdown
Contributor Author

I was actually much in doubt about the anonymous function. Would you like to put a comment on it? So I can learn for future reference. If not it's also fine I have an idea why 😊

@josevalim

Copy link
Copy Markdown
Member

Nothing wrong with having it but I personally didn't think the indirection was worth it for something that happens twice. Three times I'd agree :D

@MikaelFangel

Copy link
Copy Markdown
Contributor Author

Thank you ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Enum.slide doesn't match the semantics of Enum.slice and can hang on large negative out-of-bounds indexes

2 participants