| ... | @@ -26,8 +26,11 @@ fn log2_workaround(x: var) -> @typeOf(x) { | ... | @@ -26,8 +26,11 @@ fn log2_workaround(x: var) -> @typeOf(x) { |
| 26 | else => @compileError("log2 not implemented for " ++ @typeName(T)), | 26 | else => @compileError("log2 not implemented for " ++ @typeName(T)), |
| 27 | }; | 27 | }; |
| 28 | }, | 28 | }, |
| 29 | TypeId.IntLiteral => { | 29 | TypeId.IntLiteral => comptime { |
| 30 | return @typeOf(1)(log2_int(u128, x)) | 30 | var result = 0; |
| | 31 | var x_shifted = x; |
| | 32 | while ({x_shifted >>= 1; x_shifted != 0}) : (result += 1) {} |
| | 33 | return result; |
| 31 | }, | 34 | }, |
| 32 | TypeId.Int => { | 35 | TypeId.Int => { |
| 33 | return log2_int(T, x); | 36 | return log2_int(T, x); |