MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / bi_reverse

Function bi_reverse

zlib/trees.c:1146–1156  ·  view source on GitHub ↗

=========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */

(code, len)

Source from the content-addressed store, hash-verified

1144 * IN assertion: 1 <= len <= 15
1145 */
1146local unsigned bi_reverse(code, len)
1147 unsigned code; /* the value to invert */
1148 int len; /* its bit length */
1149{
1150 register unsigned res = 0;
1151 do {
1152 res |= code & 1;
1153 code >>= 1, res <<= 1;
1154 } while (--len > 0);
1155 return res >> 1;
1156}
1157
1158/* ===========================================================================
1159 * Flush the bit buffer, keeping at most 7 bits in it.

Callers 2

tr_static_initFunction · 0.85
gen_codesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected