feat: add property filter caching and size hint for JSON5 serialization

- Introduced a `PropertyFilterCache` to optimize property filtering during syncback, reducing repeated superclass-chain walks in the reflection database.
- Added a `size_hint` method to `Json5Value` for estimating byte size during JSON5 serialization, improving performance by pre-allocating output strings based on value types.
- Updated `syncback` logic to utilize the new caching mechanism for filtering properties, enhancing efficiency in the syncback process.
This commit is contained in:
Joe 2026-03-13 17:21:00 -05:00
parent f95035d5ad
commit 1e24a1cb2d
6 changed files with 321 additions and 160 deletions

View file

@ -13,7 +13,7 @@ use crate::{
json,
resolution::UnresolvedValue,
snapshot::{InstanceContext, InstanceSnapshot},
syncback::{filter_properties_preallocated, FsSnapshot, SyncbackReturn, SyncbackSnapshot},
syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot},
RojoRef,
};
@ -126,7 +126,7 @@ fn json_model_from_pair<'sync>(
.get_new_instance(new)
.expect("all new referents passed to json_model_from_pair should exist");
filter_properties_preallocated(snapshot.project(), new_inst, prop_buffer);
snapshot.filter_properties_cached(new_inst, prop_buffer);
let mut properties = IndexMap::new();
let mut attributes = IndexMap::new();