Skip to content

Commit f64de31

Browse files
committed
(chore) some cosmetic changes after #93
1 parent 894ecba commit f64de31

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

assembly/globals.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,11 @@ export function __floatuntfdi(value: f64): u64 {
238238
*/
239239
// @ts-ignore: decorator
240240
@global @inline
241-
export function __clz128(lo: u64, hi: i64): i32 {
242-
let h: u64 = <u64>hi; // reinterpret hi as unsigned
243-
if (h == 0) {
244-
// If hi is 0, the leading zeros are "64 plus however many are in lo"
245-
return 64 + <i32>i64.clz(lo);
241+
export function __clz128(lo: u64, hi: u64): i32 {
242+
if (hi == 0) {
243+
return <i32>clz(lo) + 64;
246244
} else {
247-
// The top 64 bits are set => just measure their leading zeros
248-
return <i32>i64.clz(h);
245+
return <i32>clz(hi);
249246
}
250247
}
251248

@@ -260,11 +257,9 @@ export function __clz128(lo: u64, hi: i64): i32 {
260257
@global @inline
261258
export function __ctz128(lo: u64, hi: u64): i32 {
262259
if (lo == 0) {
263-
// Otherwise, ctz is 64 plus ctz(hi)
264-
return 64 + <i32>i64.ctz(hi);
260+
return <i32>ctz(hi) + 64;
265261
} else {
266-
// If the lower 64 bits are non-zero, measure ctz(lo)
267-
return <i32>i64.ctz(lo);
262+
return <i32>ctz(lo);
268263
}
269264
}
270265

0 commit comments

Comments
 (0)