Skip to content

Commit b53fa85

Browse files
committed
use ilog2
1 parent e7a49f8 commit b53fa85

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

compiler/rustc_codegen_ssa/src/mir/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,10 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
284284
//
285285
// Taken from Cargo:
286286
// https://github.com/rust-lang/cargo/blob/2ce45605d9db521b5fd6c1211ce8de6055fdb24e/src/cargo/util/mod.rs#L88-L95
287-
pub fn human_readable_bytes(bytes: u64) -> (f32, &'static str) {
287+
pub fn human_readable_bytes(bytes: u64) -> (u64, &'static str) {
288288
static UNITS: [&str; 7] = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"];
289-
let bytes = bytes as f32;
290-
let i = ((bytes.log2() / 10.0) as usize).min(UNITS.len() - 1);
291-
(bytes / 1024_f32.powi(i as i32), UNITS[i])
289+
let i = ((bytes.ilog2() / 10) as usize).min(UNITS.len() - 1);
290+
(bytes >> (10 * i), UNITS[i])
292291
}
293292

294293
/// Produces, for each argument, a `Value` pointing at the
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)