mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
arch: use bit-shift expressions for cache size units
Replace 1024, 1024u32.pow(2), and 1024u32.pow(3) with 1u32 << 10, 1u32 << 20, and 1u32 << 30 in get_cache_size. The shift form makes the binary (KiB/MiB/GiB) nature of the conversion immediately obvious and is easier to read at a glance. Signed-off-by: Anirudh Rayabharam <anrayabh@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
2bb02d51ed
commit
c30732c9c1
@@ -42,9 +42,9 @@ pub fn get_cache_size(cache_level: CacheLevel) -> u32 {
|
||||
|
||||
src_digits
|
||||
* match src_unit {
|
||||
"K" => 1024,
|
||||
"M" => 1024u32.pow(2),
|
||||
"G" => 1024u32.pow(3),
|
||||
"K" => 1u32 << 10,
|
||||
"M" => 1u32 << 20,
|
||||
"G" => 1u32 << 30,
|
||||
_ => 1,
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user