renpy-0001: ShownImageInfo.choose_image() list membership O(I*A*(R+O)), 5.9x

This commit is contained in:
russell@unturf.com 2026-03-31 12:17:11 -04:00
parent 9fac7766ba
commit bf67964b10
2 changed files with 154 additions and 0 deletions

View file

@ -0,0 +1,35 @@
# UNDF: UNDF-2026-000000969
--- a/renpy/display/image.py
+++ b/renpy/display/image.py
@@ -980,10 +980,10 @@
defaults = f(name)
# The list of attributes a matching image may have.
- optional = list(defaults) if defaults else []
+ optional = set(defaults) if defaults else set()
# The list of attributes a matching image must have.
- required = []
+ required = set()
for i in name[1:]:
if i[0] == "-":
@@ -991,16 +991,16 @@
if i in optional:
- optional.remove(i)
+ optional.discard(i)
if i in required:
- required.remove(i)
+ required.discard(i)
else:
- required.append(i)
+ required.add(i)
return self.choose_image(nametag, required, optional, name)
def choose_image(self, tag, required, optional, exception_name):
# The longest length of an image that matches.
max_len = -1