From 0de09cd794e300e14fa17ceea0e59d7f8949f875 Mon Sep 17 00:00:00 2001 From: Mysteryem Date: Sat, 21 Feb 2026 14:16:57 +0000 Subject: [PATCH] Core: Better scaling explicit indirect conditions (#4582) * Core: Better scaling explicit indirect conditions When the number of connections to retry was large and `queue` was large `new_entrance not in queue` would get slow. For the average supported world, the difference this change makes is negligible. For a game like Blasphemous, with a lot of explicit indirect conditions, generation of 10 template Blasphemous yamls with `--skip_output --seed 1` and progression balancing disabled went from 19.0s to 17.9s (5.9% reduction in generation duration). * Create a new variable for the new set created from the intersection --- BaseClasses.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BaseClasses.py b/BaseClasses.py index d1b9b5f6d3..ccb8e0677f 100644 --- a/BaseClasses.py +++ b/BaseClasses.py @@ -788,9 +788,11 @@ class CollectionState(): self.multiworld.worlds[player].reached_region(self, new_region) # Retry connections if the new region can unblock them - for new_entrance in self.multiworld.indirect_connections.get(new_region, set()): - if new_entrance in blocked_connections and new_entrance not in queue: - queue.append(new_entrance) + entrances = self.multiworld.indirect_connections.get(new_region) + if entrances is not None: + relevant_entrances = entrances.intersection(blocked_connections) + relevant_entrances.difference_update(queue) + queue.extend(relevant_entrances) def _update_reachable_regions_auto_indirect_conditions(self, player: int, queue: deque[Entrance]): reachable_regions = self.reachable_regions[player]