Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui_shared_string: Avoid intermediate string allocation when deserializing a `SharedString` (#65089)

Finn Evers9dd6993e2e6e
diff --git a/Cargo.lock b/Cargo.lock
index b5f5dcf5f63..cd7027eb0f2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17164,7 +17164,6 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aaa7368fcf4852a4c2dd92df0cace6a71f2091ca0a23391ce7f3a31833f1523"
dependencies = [
- "borsh",
"serde_core",
]
diff --git a/crates/gpui_shared_string/Cargo.toml b/crates/gpui_shared_string/Cargo.toml
index c3ba8736215..4d8787e5b8e 100644
--- a/crates/gpui_shared_string/Cargo.toml
+++ b/crates/gpui_shared_string/Cargo.toml
@@ -13,7 +13,7 @@ doctest = false
[dependencies]
schemars.workspace = true
serde.workspace = true
-smol_str = "0.3.6"
+smol_str = { version = "0.3.6", default-features = false, features = ["serde"] }
[lints]
workspace = true
diff --git a/crates/gpui_shared_string/gpui_shared_string.rs b/crates/gpui_shared_string/gpui_shared_string.rs
index 8449c065ad2..bdb9e27453c 100644
--- a/crates/gpui_shared_string/gpui_shared_string.rs
+++ b/crates/gpui_shared_string/gpui_shared_string.rs
@@ -205,7 +205,6 @@ impl<'de> Deserialize<'de> for SharedString {
where
D: serde::Deserializer<'de>,
{
- let s = String::deserialize(deserializer)?;
- Ok(SharedString::new(&s))
+ SmolStr::deserialize(deserializer).map(SharedString)
}
}