Skip to content

Commit

Permalink
perf: reduce extra allocation at `WebViewBuilderExtWindows::with_addi…
Browse files Browse the repository at this point in the history
…tional_browser_args` argument (#783)
  • Loading branch information
rhysd committed Dec 3, 2022
1 parent db1c290 commit b0ff06a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/prefer-into-to-asref-to-reduce-alloc.md
@@ -0,0 +1,5 @@
---
"wry": "minor"
---

Change the type of `WebViewBuilderExtWindows::with_additional_browser_args` argument from `AsRef<str>` to `Into<String>` to reduce extra allocation.
6 changes: 3 additions & 3 deletions src/webview/mod.rs
Expand Up @@ -592,13 +592,13 @@ pub trait WebViewBuilderExtWindows {
///
/// By default wry passes `--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection`
/// so if you use this method, you also need to disable these components by yourself if you want.
fn with_additional_browser_args<S: AsRef<str>>(self, additional_args: S) -> Self;
fn with_additional_browser_args<S: Into<String>>(self, additional_args: S) -> Self;
}

#[cfg(windows)]
impl WebViewBuilderExtWindows for WebViewBuilder<'_> {
fn with_additional_browser_args<S: AsRef<str>>(mut self, additional_args: S) -> Self {
self.platform_specific.additional_browser_args = Some(additional_args.as_ref().to_string());
fn with_additional_browser_args<S: Into<String>>(mut self, additional_args: S) -> Self {
self.platform_specific.additional_browser_args = Some(additional_args.into());
self
}
}
Expand Down

0 comments on commit b0ff06a

Please sign in to comment.