diff options
Diffstat (limited to 'platforms/tortuise-script-compiled/src/storage.rs')
| -rw-r--r-- | platforms/tortuise-script-compiled/src/storage.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/platforms/tortuise-script-compiled/src/storage.rs b/platforms/tortuise-script-compiled/src/storage.rs index d028a91..033bacb 100644 --- a/platforms/tortuise-script-compiled/src/storage.rs +++ b/platforms/tortuise-script-compiled/src/storage.rs @@ -37,6 +37,7 @@ impl<T: Serialize + DeserializeOwned + Clone + Eq> Storage<T> { } pub fn load(&self, context: &ScriptContext) -> T { + #[cfg(feature = "profiling")] puffin::profile_function!(); let mut data = self.data.lock(); data.get_or_insert_with(|| { @@ -78,6 +79,7 @@ impl<T: Serialize + DeserializeOwned + Clone + Eq> Config<T> { } pub fn load(&self, context: &ScriptContext) -> T { + #[cfg(feature = "profiling")] puffin::profile_function!(); let mut data = self.data.lock(); data.get_or_insert_with(|| { @@ -85,7 +87,7 @@ impl<T: Serialize + DeserializeOwned + Clone + Eq> Config<T> { .0 .storage .config() - .map(toml::from_slice) + .map(serde_json::from_slice) .and_then(|r| r.ok()) .unwrap_or_else(self.initial_state) }) @@ -126,6 +128,7 @@ impl<T: Serialize + Eq> DerefMut for StorageMut<'_, '_, T> { impl<T: Serialize + Eq> Drop for StorageMut<'_, '_, T> { fn drop(&mut self) { + #[cfg(feature = "profiling")] puffin::profile_function!(); if self.data == self.original { return; @@ -161,13 +164,14 @@ impl<T: Serialize + Eq> DerefMut for ConfigMut<'_, '_, T> { impl<T: Serialize + Eq> Drop for ConfigMut<'_, '_, T> { fn drop(&mut self) { + #[cfg(feature = "profiling")] puffin::profile_function!(); if self.data == self.original { return; } - let new_save = match toml::to_string(&self.data) { - Ok(new_save) => new_save.as_bytes().into(), + let new_save = match serde_json::to_vec_pretty(&self.data) { + Ok(new_save) => new_save.into(), Err(e) => { log::error!("{e}"); return; |
