@@ -45,11 +45,13 @@ pub fn leading_zeros_64(x u64) int {
4545
4646// --- TrailingZeros ---
4747// trailing_zeros_8 returns the number of trailing zero bits in x; the result is 8 for x == 0.
48+ @[direct_array_access]
4849pub fn trailing_zeros_8 (x u8 ) int {
4950 return int (ntz_8_ tab[x])
5051}
5152
5253// trailing_zeros_16 returns the number of trailing zero bits in x; the result is 16 for x == 0.
54+ @[direct_array_access]
5355pub fn trailing_zeros_16 (x u16 ) int {
5456 if x == 0 {
5557 return 16
@@ -59,6 +61,7 @@ pub fn trailing_zeros_16(x u16) int {
5961}
6062
6163// trailing_zeros_32 returns the number of trailing zero bits in x; the result is 32 for x == 0.
64+ @[direct_array_access]
6265pub fn trailing_zeros_32 (x u32 ) int {
6366 if x == 0 {
6467 return 32
@@ -68,6 +71,7 @@ pub fn trailing_zeros_32(x u32) int {
6871}
6972
7073// trailing_zeros_64 returns the number of trailing zero bits in x; the result is 64 for x == 0.
74+ @[direct_array_access]
7175pub fn trailing_zeros_64 (x u64 ) int {
7276 if x == 0 {
7377 return 64
@@ -88,16 +92,19 @@ pub fn trailing_zeros_64(x u64) int {
8892
8993// --- OnesCount ---
9094// ones_count_8 returns the number of one bits ("population count") in x.
95+ @[direct_array_access]
9196pub fn ones_count_8 (x u8 ) int {
9297 return int (pop_8_ tab[x])
9398}
9499
95100// ones_count_16 returns the number of one bits ("population count") in x.
101+ @[direct_array_access]
96102pub fn ones_count_16 (x u16 ) int {
97103 return int (pop_8_ tab[x >> 8 ] + pop_8_ tab[x & u16 (0xff )])
98104}
99105
100106// ones_count_32 returns the number of one bits ("population count") in x.
107+ @[direct_array_access]
101108pub fn ones_count_32 (x u32 ) int {
102109 return int (pop_8_ tab[x >> 24 ] + pop_8_ tab[x >> 16 & 0xff ] + pop_8_ tab[x >> 8 & 0xff ] +
103110 pop_8_ tab[x & u32 (0xff )])
@@ -181,13 +188,13 @@ pub fn rotate_left_64(x u64, k int) u64 {
181188
182189// --- Reverse ---
183190// reverse_8 returns the value of x with its bits in reversed order.
184- @[inline]
191+ @[direct_array_access; inline]
185192pub fn reverse_8 (x u8 ) u8 {
186193 return rev_8_ tab[x]
187194}
188195
189196// reverse_16 returns the value of x with its bits in reversed order.
190- @[inline]
197+ @[direct_array_access; inline]
191198pub fn reverse_16 (x u16 ) u16 {
192199 return u16 (rev_8_ tab[x >> 8 ]) | (u16 (rev_8_ tab[x & u16 (0xff )]) << 8 )
193200}
@@ -240,11 +247,13 @@ pub fn reverse_bytes_64(x u64) u64 {
240247
241248// --- Len ---
242249// len_8 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
250+ @[direct_array_access]
243251pub fn len_8 (x u8 ) int {
244252 return int (len_8_ tab[x])
245253}
246254
247255// len_16 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
256+ @[direct_array_access]
248257pub fn len_16 (x u16 ) int {
249258 mut y := x
250259 mut n := 0
@@ -256,6 +265,7 @@ pub fn len_16(x u16) int {
256265}
257266
258267// len_32 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
268+ @[direct_array_access]
259269pub fn len_32 (x u32 ) int {
260270 mut y := x
261271 mut n := 0
@@ -271,6 +281,7 @@ pub fn len_32(x u32) int {
271281}
272282
273283// len_64 returns the minimum number of bits required to represent x; the result is 0 for x == 0.
284+ @[direct_array_access]
274285pub fn len_64 (x u64 ) int {
275286 mut y := x
276287 mut n := 0
0 commit comments