mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-05-03 21:40:32 +00:00
chore: fix certain uninlined string format uses (#1310)
* Fixed uninlined args First ran this, and fixed a few more similar issues by hand ``` cargo clippy --workspace --fix --benches --tests --bins -- -A clippy::all -W clippy::uninlined_format_args ``` Note that in a few cases, format args were passed by ref - which is actually a tiny perf hit - compiler would not be able to optimize them. * revert change here since it contains a non-inlineable variable I'm not a fan of using it partially here * revert given the other formats above/below I would prefer keeping it like this --------- Co-authored-by: Clement Tsang <34804052+ClementTsang@users.noreply.github.com>
This commit is contained in:
@@ -76,10 +76,10 @@ pub fn get_decimal_bytes(bytes: u64) -> (f64, &'static str) {
|
||||
pub fn get_binary_prefix(quantity: u64, unit: &str) -> (f64, String) {
|
||||
match quantity {
|
||||
b if b < KIBI_LIMIT => (quantity as f64, unit.to_string()),
|
||||
b if b < MEBI_LIMIT => (quantity as f64 / 1024.0, format!("Ki{}", unit)),
|
||||
b if b < GIBI_LIMIT => (quantity as f64 / 1_048_576.0, format!("Mi{}", unit)),
|
||||
b if b < TERA_LIMIT => (quantity as f64 / 1_073_741_824.0, format!("Gi{}", unit)),
|
||||
_ => (quantity as f64 / 1_099_511_627_776.0, format!("Ti{}", unit)),
|
||||
b if b < MEBI_LIMIT => (quantity as f64 / 1024.0, format!("Ki{unit}")),
|
||||
b if b < GIBI_LIMIT => (quantity as f64 / 1_048_576.0, format!("Mi{unit}")),
|
||||
b if b < TERA_LIMIT => (quantity as f64 / 1_073_741_824.0, format!("Gi{unit}")),
|
||||
_ => (quantity as f64 / 1_099_511_627_776.0, format!("Ti{unit}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,10 +89,10 @@ pub fn get_binary_prefix(quantity: u64, unit: &str) -> (f64, String) {
|
||||
pub fn get_decimal_prefix(quantity: u64, unit: &str) -> (f64, String) {
|
||||
match quantity {
|
||||
b if b < KILO_LIMIT => (quantity as f64, unit.to_string()),
|
||||
b if b < MEGA_LIMIT => (quantity as f64 / 1000.0, format!("K{}", unit)),
|
||||
b if b < GIGA_LIMIT => (quantity as f64 / 1_000_000.0, format!("M{}", unit)),
|
||||
b if b < TERA_LIMIT => (quantity as f64 / 1_000_000_000.0, format!("G{}", unit)),
|
||||
_ => (quantity as f64 / 1_000_000_000_000.0, format!("T{}", unit)),
|
||||
b if b < MEGA_LIMIT => (quantity as f64 / 1000.0, format!("K{unit}")),
|
||||
b if b < GIGA_LIMIT => (quantity as f64 / 1_000_000.0, format!("M{unit}")),
|
||||
b if b < TERA_LIMIT => (quantity as f64 / 1_000_000_000.0, format!("G{unit}")),
|
||||
_ => (quantity as f64 / 1_000_000_000_000.0, format!("T{unit}")),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user