Skip to content

Commit 0974ff6

Browse files
committed
[launchk] do not compile regex repeatedly, set 2 fps for cursive (autorefresh sets 30 by default)
1 parent 62be76f commit 0974ff6

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

launchk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "launchk"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
authors = ["David Stancu <[email protected]>"]
55
edition = "2018"
66

launchk/src/launchd/command.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ pub fn read_disabled(domain_type: DomainType) -> Result<(usize, XPCShmem), XPCEr
248248
Ok((usize::try_from(bytes_written).unwrap(), shmem))
249249
}
250250

251+
lazy_static! {
252+
static ref DISABLED_RE: Regex = Regex::new(r#""([\w.]+)" => disabled"#).expect("Must compile");
253+
}
254+
251255
pub fn read_disabled_hashset(domain_type: DomainType) -> Result<HashSet<String>, XPCError> {
252256
let (sz, shmem) = read_disabled(domain_type)?;
253257

@@ -257,10 +261,7 @@ pub fn read_disabled_hashset(domain_type: DomainType) -> Result<HashSet<String>,
257261
let cs = unsafe { CString::from_vec_unchecked(data) };
258262

259263
// Find all the quoted service names
260-
let re =
261-
Regex::new(r#""([\w.]+)" => disabled"#).map_err(|e| XPCError::ValueError(e.to_string()))?;
262-
263-
let services: Vec<String> = re
264+
let services: Vec<String> = DISABLED_RE
264265
.captures_iter(cs.to_str().unwrap())
265266
.flat_map(|c| c.iter().flatten().map(|m| m.as_str().to_string()).last())
266267
.collect();

launchk/src/tui/root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ impl RootLayout {
6060
let cbsink_channel = RootLayout::cbsink_channel(siv);
6161

6262
runtime_handle.spawn(poll_omnibox(cbsink_channel.clone(), omnibox_rx));
63-
siv.set_autorefresh(true);
6463

6564
let mut new = Self {
6665
omnibox_tx,
@@ -70,6 +69,7 @@ impl RootLayout {
7069
key_ring: VecDeque::with_capacity(3),
7170
};
7271

72+
siv.set_fps(2);
7373
new.setup(omnibox);
7474
new
7575
}

0 commit comments

Comments
 (0)