Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eachindex and SOneTo #812

Closed
mateuszbaran opened this issue Jul 20, 2020 · 2 comments · Fixed by #819
Closed

eachindex and SOneTo #812

mateuszbaran opened this issue Jul 20, 2020 · 2 comments · Fixed by #819

Comments

@mateuszbaran
Copy link
Collaborator

mateuszbaran commented Jul 20, 2020

While investigating another issue I've noticed that eachindex on static arrays returns Base.OneTo while it could return SOneTo. Is this intentional or just an oversight?

julia> using StaticArrays

julia> M = SA[1 2; 3 4]
2×2 SArray{Tuple{2,2},Int64,2,4} with indices SOneTo(2)×SOneTo(2):
 1  2
 3  4

julia> eachindex(M)
Base.OneTo(4)
@andyferris
Copy link
Member

It would be an oversight. There is some more work to be done on the indexing side, for sure.

However I'd be curious where it matters much; eachindex generally used in a for loop (rather than an argument of foreach for example), and constant propagation is pretty good these days, so I'm not sure if it would affect any loop unrolling or similar?

@mateuszbaran
Copy link
Collaborator Author

I don't know if it matters anywhere and I'm not even sure if this would be an all-around improvement since I can imagine some code special-casing Base.OneTo.

@mateuszbaran mateuszbaran linked a pull request Aug 26, 2020 that will close this issue
@c42f c42f closed this as completed in #819 Sep 16, 2020
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 a pull request may close this issue.

2 participants