fix(backend): improve memory usage by making schema RawValue instead of serde_json::Value

This commit is contained in:
Ruben Fiszel
2024-05-20 10:11:47 +02:00
parent 4a49dc6df4
commit f1bb7cfcbd
+2 -5
View File
@@ -18,7 +18,6 @@ use crate::{
};
use serde::de::Error as _;
use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize};
use serde_json::to_string_pretty;
use crate::utils::StripPath;
@@ -227,13 +226,11 @@ pub struct ScriptHistoryUpdate {
#[derive(Serialize, Deserialize, Debug, sqlx::Type)]
#[sqlx(transparent)]
#[serde(transparent)]
pub struct Schema(pub serde_json::Value);
pub struct Schema(pub sqlx::types::Json<Box<serde_json::value::RawValue>>);
impl Hash for Schema {
fn hash<H: Hasher>(&self, state: &mut H) {
if let Ok(s) = to_string_pretty(&self.0) {
s.hash(state);
}
self.0.get().hash(state);
}
}