Skip to content

Conversation

@ArekSredzki
Copy link

This allows the compiler to optimize the modulo operation into a bitwise and.

This allows the compiler to optimize the modulo operation into a bitwise and.
Copy link
Contributor

@Bobobalink Bobobalink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I avoided doing this at first because I was afraid of it causing a large amount of unexpected space overhead, though I agree that it's a good change for runtime reasons.

Do you have any profiling data to show that this is really meaningful? I would be curious to see if the compiler can do other tricks to make modulo faster even for non-powers of two, since this is definitely a compile-time constant.

@alexkaratarakis
Copy link
Collaborator

Windows tests are failing:

 D:\a\fixed-containers\fixed-containers\test\fixed_unordered_set_test.cpp(68,32): error C2131: expression did not evaluate to a constant [D:\a\fixed-containers\fixed-containers\build\fixed_unordered_set_test.vcxproj]
      D:\a\fixed-containers\fixed-containers\include\fixed_containers\fixed_robinhood_hashtable.hpp(180,30):
      failure was caused by evaluation exceeding step limit of 1048576 (/constexpr:steps<NUMBER>)

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.

3 participants