mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Allocate theme struct directly into the heap
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-Authored-By: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
parent
58987275fc
commit
7cef4a5d40
@ -55,13 +55,13 @@ impl ThemeRegistry {
|
||||
.load(&asset_path)
|
||||
.with_context(|| format!("failed to load theme file {}", asset_path))?;
|
||||
|
||||
let mut theme: Theme = fonts::with_font_cache(self.font_cache.clone(), || {
|
||||
// Allocate into the heap directly, the Theme struct is too large to fit in the stack.
|
||||
let mut theme: Arc<Theme> = fonts::with_font_cache(self.font_cache.clone(), || {
|
||||
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&theme_json))
|
||||
})?;
|
||||
|
||||
// Reset name to be the file path, so that we can use it to access the stored themes
|
||||
theme.meta.name = name.into();
|
||||
let theme = Arc::new(theme);
|
||||
Arc::get_mut(&mut theme).unwrap().meta.name = name.into();
|
||||
self.themes.lock().insert(name.to_string(), theme.clone());
|
||||
Ok(theme)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user