Skip to content

Commit

Permalink
perf(logging): avoid extra heap allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed May 26, 2022
1 parent bc22ab6 commit 8594e72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions komorebi/src/window.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::convert::TryFrom;
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Write as _;

use color_eyre::eyre::anyhow;
use color_eyre::Result;
Expand Down Expand Up @@ -36,18 +37,18 @@ impl Display for Window {
let mut display = format!("(hwnd: {}", self.hwnd);

if let Ok(title) = self.title() {
display.push_str(&format!(", title: {}", title));
write!(display, ", title: {}", title)?;
}

if let Ok(exe) = self.exe() {
display.push_str(&format!(", exe: {}", exe));
write!(display, ", exe: {}", exe)?;
}

if let Ok(class) = self.class() {
display.push_str(&format!(", class: {}", class));
write!(display, ", class: {}", class)?;
}

display.push(')');
write!(display, ")")?;

write!(f, "{}", display)
}
Expand Down
2 changes: 1 addition & 1 deletion komorebi/src/winevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_EVENTID_START;
use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_PROPID_END;
use windows::Win32::UI::WindowsAndMessaging::EVENT_UIA_PROPID_START;

#[derive(Clone, Copy, PartialEq, Debug, Serialize, Display, JsonSchema)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Display, JsonSchema)]
#[repr(u32)]
#[allow(dead_code)]
pub enum WinEvent {
Expand Down

0 comments on commit 8594e72

Please sign in to comment.