Perf enhancement fixes

This commit is contained in:
aerinon
2021-08-03 13:49:46 -06:00
parent e10c765bc2
commit 4b29408911

View File

@@ -564,10 +564,11 @@ def balance_multiworld_progression(world):
replaced_items = False replaced_items = False
# sort then shuffle to maintain deterministic behaviour, # sort then shuffle to maintain deterministic behaviour,
# while allowing use of set for better algorithm growth behaviour elsewhere # while allowing use of set for better algorithm growth behaviour elsewhere
replacement_locations = sorted(l for l in checked_locations if not l.event and not l.locked) replacement_locations = sorted((l for l in checked_locations if not l.event and not l.locked),
world.random.shuffle(replacement_locations) key=lambda loc: (loc.name, loc.player))
items_to_replace.sort() random.shuffle(replacement_locations)
world.random.shuffle(items_to_replace) items_to_replace.sort(key=lambda item: (item.name, item.player))
random.shuffle(items_to_replace)
while replacement_locations and items_to_replace: while replacement_locations and items_to_replace:
old_location = items_to_replace.pop() old_location = items_to_replace.pop()
for new_location in replacement_locations: for new_location in replacement_locations: