Do not clone during scene coherence fixing
This commit is contained in:
parent
fed6d2581d
commit
02a4897b4b
|
@ -139,7 +139,7 @@ pub fn make_scene_from_stub_coherent(content: &mut ContentContainer, connected_s
|
|||
keep
|
||||
});
|
||||
|
||||
// Delete corresponding stubs
|
||||
// 2. Delete corresponding scene stubs
|
||||
content.contained.retain(|c| match &c.content {
|
||||
Content::SceneStub(stub) => match stub._key.as_ref() {
|
||||
Some(key) => !stubs_to_delete.contains(key),
|
||||
|
@ -148,7 +148,7 @@ pub fn make_scene_from_stub_coherent(content: &mut ContentContainer, connected_s
|
|||
_ => true,
|
||||
});
|
||||
|
||||
// Add new linkback exit
|
||||
// 3. Add new linkback exit
|
||||
let exit = Exit::from_connected_scene(connected_scene, &reversed_direction);
|
||||
new_scene.exits.push(exit);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ pub async fn make_scene_coherent(
|
|||
let scene = content.owner.as_scene_mut();
|
||||
let failures = check_scene_coherence(&scene);
|
||||
let fixes = generator.fix_scene(&scene, failures).await?;
|
||||
let mut deletes = vec![]; // Needed because we Vec::retain after the fact
|
||||
let mut deletes = vec![]; // Needed for call to Vec::retain after the fact
|
||||
|
||||
for fix in fixes {
|
||||
match fix {
|
||||
|
@ -168,15 +168,14 @@ pub async fn make_scene_coherent(
|
|||
index,
|
||||
new: fixed_exit,
|
||||
} => {
|
||||
// TODO could someday use swap_remove? only cloning
|
||||
// due to deletes below.
|
||||
let old_exit = scene.exits[index].clone();
|
||||
scene.exits[index] = fixed_exit.into();
|
||||
let old_exit_key = scene.exits[index].scene_key.as_str();
|
||||
|
||||
content.contained.retain(|c| match &c.content {
|
||||
Content::SceneStub(stub) => stub._id != old_exit.scene_id,
|
||||
Content::SceneStub(stub) => stub._key.as_deref() != Some(old_exit_key),
|
||||
_ => true,
|
||||
});
|
||||
|
||||
scene.exits[index] = fixed_exit.into();
|
||||
let fixed_exit = &scene.exits[index];
|
||||
|
||||
content
|
||||
|
|
Loading…
Reference in New Issue