Skip to content

Instantly share code, notes, and snippets.

@markpapadakis
Created October 15, 2016 17:32
Show Gist options
  • Save markpapadakis/976f574290e3cbed872129213aef2e2c to your computer and use it in GitHub Desktop.
Save markpapadakis/976f574290e3cbed872129213aef2e2c to your computer and use it in GitHub Desktop.
#ifdef __OPTIMIZE__
// Unformatelly, we can't tell if it was compiled with -O1, or higher
// It's not exposed to the compiled as a macro or feature
template<typename T1, typename T2>
static constexpr auto fastrange(const T1 word, const T2 p)
{
return sizeof(T1) < sizeof(uint64_t) && sizeof(T2) < sizeof(uint64_t) ? fastrange32(word, p) : fastrange64(word, p);
}
#else
#define fastrange(a, b) ((a) % (b))
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment