Skip to content

Commit 2c48b9b

Browse files
committed
use ilog2
1 parent e4ca961 commit 2c48b9b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,10 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
294294
//
295295
// Taken from Cargo:
296296
// https://github.com/rust-lang/cargo/blob/2ce45605d9db521b5fd6c1211ce8de6055fdb24e/src/cargo/util/mod.rs#L88-L95
297-
pub fn human_readable_bytes(bytes: u64) -> (f32, &'static str) {
297+
pub fn human_readable_bytes(bytes: u64) -> (u64, &'static str) {
298298
static UNITS: [&str; 7] = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"];
299-
let bytes = bytes as f32;
300-
let i = ((bytes.log2() / 10.0) as usize).min(UNITS.len() - 1);
301-
(bytes / 1024_f32.powi(i as i32), UNITS[i])
299+
let i = ((bytes.ilog2() / 10) as usize).min(UNITS.len() - 1);
300+
(bytes >> (10 * i), UNITS[i])
302301
}
303302

304303
/// Produces, for each argument, a `Value` pointing at the
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Dangerous stack allocation of size: 2.00 GiB exceeds limits on most architectures
1+
error: Dangerous stack allocation of size: 1 GiB exceeds limits on most architectures
22

33
error: aborting due to 1 previous error
44

0 commit comments

Comments
 (0)