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

fix circshift(::Tuple{}, ::Int) #54295

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

nsajko
Copy link
Contributor

@nsajko nsajko commented Apr 28, 2024

Fixes circshift for empty tuples.

Fixes #54294

@nsajko nsajko added kind:bugfix This change fixes an existing bug domain:collections Data structures holding multiple items, e.g. sets performance Must go faster labels Apr 28, 2024
@adienes
Copy link
Contributor

adienes commented Apr 29, 2024

circshift2(t::Tuple{L,R}, shift::Integer) where {L,R} = ifelse(iseven(shift), t, reverse(t))

is a bit faster on my machine than the length-2 implementation added here (just ifelse vs if-else mostly. not sure if the extra type assertions are needed either)

@nsajko
Copy link
Contributor Author

nsajko commented Apr 29, 2024

I think ifelse is only a good idea when L == R, otherwise it exacerbates type stability issues. I guess.

@nsajko
Copy link
Contributor Author

nsajko commented May 6, 2024

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:collections Data structures holding multiple items, e.g. sets kind:bugfix This change fixes an existing bug performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

circshift(::Tuple{}, ::Int) throws DivideError instead of returning
2 participants