Skip to content

Commit

Permalink
small refactors
Browse files Browse the repository at this point in the history
Remove thread name from log and do not lock stderr, since we only have
one thread writing to it.

Minor changes in `common` code.
  • Loading branch information
LGFae committed Aug 9, 2024
1 parent 3c148ff commit 0ae168e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions common/src/ipc/transmit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ impl From<RawMsg> for RequestRecv {

Self::Img(ImageReq {
transition,
imgs: imgs.into(),
outputs: outputs.into(),
imgs,
outputs,
animations: if animations.is_empty() {
None
} else {
Some(animations.into())
Some(animations)
},
})
}
Expand Down
2 changes: 2 additions & 0 deletions common/src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,14 @@ impl<const UTF8: bool> Mmapped<UTF8> {
const PROT: ProtFlags = ProtFlags::READ;
const FLAGS: MapFlags = MapFlags::SHARED;

#[must_use]
pub(crate) fn new(map: &Mmap, bytes: &[u8]) -> Self {
let len = u32::from_ne_bytes(bytes[0..4].try_into().unwrap()) as usize;
let bytes = &bytes[4..];
Self::new_with_len(map, bytes, len)
}

#[must_use]
pub(crate) fn new_with_len(map: &Mmap, bytes: &[u8], len: usize) -> Self {
let offset = bytes.as_ptr() as usize - map.ptr.as_ptr() as usize;
let page_size = rustix::param::page_size();
Expand Down
7 changes: 1 addition & 6 deletions daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,13 +709,8 @@ impl log::Log for Logger {
}
};

let thread = std::thread::current();
let thread_name = thread.name().unwrap_or("???");
let msg = record.args();

let _ = std::io::stderr()
.lock()
.write_fmt(format_args!("{time:>8}ms {level} ({thread_name}) {msg}\n"));
let _ = std::io::stderr().write_fmt(format_args!("{time:>10}ms {level} {msg}\n"));
}
}

Expand Down

0 comments on commit 0ae168e

Please sign in to comment.