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

Use Data.Bits.unsafeShift* instead of shift*? #569

Closed
sjakobi opened this issue Oct 7, 2018 · 5 comments
Closed

Use Data.Bits.unsafeShift* instead of shift*? #569

sjakobi opened this issue Oct 7, 2018 · 5 comments

Comments

@sjakobi
Copy link
Member

sjakobi commented Oct 7, 2018

Now that containers has base >= 4.6 it can unconditionally use unsafeShiftR and unsafeShiftL from Data.Bits which might be faster shift{R,L}.

I'm also wondering whether the many shifts by 1 should be replaced by calls to two helper functions double and half.

@AndreasPK
Copy link
Contributor

Performance of shiftL/R might soon get worse than the unsafe variants. See https://gitlab.haskell.org/ghc/ghc/merge_requests/113

@sjakobi
Copy link
Member Author

sjakobi commented Jul 29, 2019

Related: #216

@sjakobi
Copy link
Member Author

sjakobi commented Jul 29, 2019

It appears that GHC optimizes

x `shift{R,L}` 1

to

x `unsafeShift{R,L}` 1

Nonetheless it would be clearer and safer to remove the usage of shift{R,L}. That is all in Data.Map.Internal, Data.Map.Strict.Internal and Data.Set.Internal.

How about we add two functions half and double to Data.Set.Internal and use them in Data.Map.* too @treeowl?

@sjakobi
Copy link
Member Author

sjakobi commented Jul 4, 2020

I stumbled across this issue again, and I would like to get it finally resolved.

How do you feel about my comment above, @treeowl?

@meooow25
Copy link
Contributor

meooow25 commented Jan 5, 2025

There are no more shiftL/shiftR usages after #1042.

@meooow25 meooow25 closed this as completed Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants