Skip to content

Commit

Permalink
Remove String allocation in Interface's Display impl
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Oct 10, 2023
1 parent e8b23fc commit 2c759df
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions atspi-common/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl TryFrom<&str> for Interface {
}
impl std::fmt::Display for Interface {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let interface_string = match self {
let interface_str = match self {
Interface::Accessible => ACCESSIBLE_INTERFACE_NAME,
Interface::Action => ACTION_INTERFACE_NAME,
Interface::Application => APPLICATION_INTERFACE_NAME,
Expand All @@ -396,8 +396,7 @@ impl std::fmt::Display for Interface {
Interface::TableCell => TABLE_CELL_INTERFACE_NAME,
Interface::Text => TEXT_INTERFACE_NAME,
Interface::Value => VALUE_INTERFACE_NAME,
}
.to_string();
write!(f, "{interface_string}")
};
f.write_str(interface_str)
}
}

0 comments on commit 2c759df

Please sign in to comment.