MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rev

Function rev

src/dict.cpp:1155–1163  ·  view source on GitHub ↗

Function to reverse bits. Algorithm from: * http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */

Source from the content-addressed store, hash-verified

1153/* Function to reverse bits. Algorithm from:
1154 * http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */
1155static unsigned long rev(unsigned long v) {
1156 unsigned long s = CHAR_BIT * sizeof(v); // bit size; must be power of 2
1157 unsigned long mask = ~0UL;
1158 while ((s >>= 1) > 0) {
1159 mask ^= (mask << s);
1160 v = ((v >> s) & mask) | ((v << s) & ~mask);
1161 }
1162 return v;
1163}
1164
1165/* dictScan() is used to iterate over the elements of a dictionary.
1166 *

Callers 1

dictScanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected