MCPcopy Create free account
hub / github.com/PerroEngine/Perro / cached_scene_doc_shared

Function cached_scene_doc_shared

perro_editor/res/scripts/editor/main.rs:39–56  ·  view source on GitHub ↗
(text: &str)

Source from the content-addressed store, hash-verified

37 (*cached_scene_doc_shared(text)).clone()
38}
39
40pub fn cached_scene_doc_shared(text: &str) -> Arc<SceneDoc> {
41 let cache = ACTIVE_SCENE_DOC_CACHE.get_or_init(|| Mutex::new(Vec::new()));
42 let Ok(mut guard) = cache.lock() else {
43 return Arc::new(SceneDoc::parse(text));
44 };
45 if let Some(idx) = guard.iter().position(|cached| cached.text == text) {
46 let cached = guard.remove(idx);
47 let doc = cached.doc.clone();
48 guard.push(cached);
49 return doc;
50 }
51 let doc = Arc::new(SceneDoc::parse(text));
52 guard.push(CachedSceneDoc::new(text.to_string(), doc.clone()));
53 if guard.len() > SCENE_DOC_CACHE_LIMIT {
54 guard.remove(0);
55 }
56 doc
57}
58
59pub fn store_scene_doc_cache(text: &str, doc: &SceneDoc) {

Callers 15

load_preview_sceneFunction · 0.85
pick_preview_uiFunction · 0.85
pick_resize_handleFunction · 0.85
pick_rotation_zoneFunction · 0.85
selected_node_type_nameFunction · 0.85
picker_parent_node_kindFunction · 0.85
quick_asset_stemFunction · 0.85
cached_scene_docFunction · 0.85
undo_scene_docFunction · 0.85
redo_scene_docFunction · 0.85
from_stateMethod · 0.85

Calls 7

cloneMethod · 0.80
parseFunction · 0.50
positionMethod · 0.45
iterMethod · 0.45
removeMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected