fix: address reviewer feedback — rename scroll field to bool, relocate static, drop env var
- Rename `ui_scroll_tick_count: u64` → `should_text_scroll: bool` across all 33 call sites; `on_ui_scroll_tick` now assigns true/false instead of 0/1 - Remove two now-redundant comments from `test_on_ui_scroll_tick` - Move `WHITESPACE_RE` static declaration below module imports in network/mod.rs - Remove `MANAGARR_TICK_RATE_MS` env var and its parsing helpers; `recv()`-based blocking already brings idle CPU to near-0, and tuning tick rate silently stretches the poll cadence — keep `DEFAULT_TICK_RATE_MS` const only Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C3FpbniZme9mJqgFkMVowz
This commit is contained in:
1 parent
6f697f64f4
commit
645ca19d76
30 files changed
+43
-70
No files matched your search
@@ -1,5 +1,4 @@
|
||||
use anyhow::Result;
|
||||
use std::env;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::mpsc::Receiver;
|
||||
use std::thread;
|
||||
@@ -21,22 +20,10 @@ pub struct Events {
|
||||
|
||||
const DEFAULT_TICK_RATE_MS: u64 = 50;
|
||||
|
||||
fn configured_tick_rate_ms_from(raw: Option<&str>) -> u64 {
|
||||
raw
|
||||
.and_then(|value| value.parse::<u64>().ok())
|
||||
.filter(|ms| *ms > 0)
|
||||
.unwrap_or(DEFAULT_TICK_RATE_MS)
|
||||
}
|
||||
|
||||
fn configured_tick_rate_ms() -> u64 {
|
||||
let raw = env::var("MANAGARR_TICK_RATE_MS").ok();
|
||||
configured_tick_rate_ms_from(raw.as_deref())
|
||||
}
|
||||
|
||||
impl Events {
|
||||
pub fn new() -> Self {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let tick_rate: Duration = Duration::from_millis(configured_tick_rate_ms());
|
||||
let tick_rate: Duration = Duration::from_millis(DEFAULT_TICK_RATE_MS);
|
||||
|
||||
thread::spawn(move || {
|
||||
let mut last_tick = Instant::now();
|
||||
@@ -80,16 +67,5 @@ mod tests {
|
||||
#[test]
|
||||
fn defaults_to_original_tick_rate() {
|
||||
assert_eq!(DEFAULT_TICK_RATE_MS, 50);
|
||||
assert_eq!(configured_tick_rate_ms_from(None), 50);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_positive_tick_rates_and_rejects_invalid_values() {
|
||||
assert_eq!(configured_tick_rate_ms_from(Some("250")), 250);
|
||||
assert_eq!(configured_tick_rate_ms_from(Some("0")), DEFAULT_TICK_RATE_MS);
|
||||
assert_eq!(
|
||||
configured_tick_rate_ms_from(Some("abc")),
|
||||
DEFAULT_TICK_RATE_MS
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user