refactor: use CompactString for formatting in Proxy conversion and TUI drawing

This commit is contained in:
monosans
2025-12-25 10:57:44 +03:00
parent 2060b10de7
commit a3ce923a14
2 changed files with 20 additions and 14 deletions
+9 -6
View File
@@ -65,12 +65,15 @@ impl TryFrom<&mut Proxy> for reqwest::Proxy {
#[inline]
fn try_from(value: &mut Proxy) -> Result<Self, Self::Error> {
let proxy = Self::all(format!(
"{}://{}:{}",
value.protocol.as_str(),
value.host,
value.port
))?;
let proxy = Self::all(
compact_str::format_compact!(
"{}://{}:{}",
value.protocol.as_str(),
value.host,
value.port
)
.as_str(),
)?;
if let (Some(username), Some(password)) =
(value.username.as_ref(), value.password.as_ref())
+11 -8
View File
@@ -272,14 +272,17 @@ fn draw(f: &mut Frame<'_>, state: &AppState, logger_state: &TuiWidgetState) {
let proxies_working =
state.proxies_working.get(proxy_type).copied().unwrap_or_default();
f.render_widget(
Line::from(format!("{} ({:.1}%)", proxies_working, {
if proxies_checked == 0 {
0.0_f64
} else {
(proxies_working as f64) / (proxies_checked as f64)
* 100.0_f64
}
}))
Line::from(
compact_str::format_compact!("{} ({:.1}%)", proxies_working, {
if proxies_checked == 0 {
0.0_f64
} else {
(proxies_working as f64) / (proxies_checked as f64)
* 100.0_f64
}
})
.as_str(),
)
.alignment(Alignment::Center),
working_proxies_block.inner(layout[2]),
);