dict iteration optimizations

This commit is contained in:
Asriel Senna
2022-09-24 18:27:35 +02:00
parent a59f9e9b6b
commit 9b884d3e01
4 changed files with 14 additions and 14 deletions
+2 -2
View File
@@ -1352,9 +1352,9 @@ class Input(renpy.text.text.Text): # @UndefinedVariable
caretprops = { 'color' : None }
for i in properties:
for i, v in properties.items():
if i.endswith("color"):
caretprops[i] = properties[i]
caretprops[i] = v
caret = renpy.display.image.Solid(xysize=(1, renpy.store.preferences.font_size), style=style, **caretprops)
+10 -10
View File
@@ -1333,8 +1333,8 @@ class SceneLists(renpy.object.Object):
for l, (t, ll) in list(self.layer_at_list.items()):
self.layer_at_list[l] = (t or time, ll)
for l, ll in self.layers.items():
self.layers[l][:] = [ i.update_time(time) for i in ll ]
for ll in self.layers.values():
ll[:] = [ i.update_time(time) for i in ll ]
def showing(self, layer, name):
"""
@@ -1467,10 +1467,10 @@ class SceneLists(renpy.object.Object):
now = get_time()
for l in self.layers:
for v in self.layers.values():
newl = [ ]
for sle in self.layers[l]:
for sle in v:
if sle.tag:
@@ -1486,17 +1486,17 @@ class SceneLists(renpy.object.Object):
newl.append(sle)
self.layers[l][:] = newl
v[:] = newl
def remove_all_hidden(self):
"""
Removes everything hidden, even if it's not time yet. (Used when making a rollback copy).
"""
for l in self.layers:
for v in self.layers.values():
newl = [ ]
for sle in self.layers[l]:
for sle in v:
if sle.tag:
@@ -1505,7 +1505,7 @@ class SceneLists(renpy.object.Object):
newl.append(sle)
self.layers[l][:] = newl
v[:] = newl
def get_displayable_by_tag(self, layer, tag):
"""
@@ -3606,11 +3606,11 @@ class Interface(object):
self.transition_from.clear()
self.transition_time.clear()
else:
for k in self.transition:
for k, t in self.transition.items():
if k not in self.old_scene:
continue
self.ongoing_transition[k] = self.transition[k]
self.ongoing_transition[k] = t
self.transition_from[k] = self.old_scene[k]._in_current_store()
self.transition_time[k] = None
+1 -1
View File
@@ -1761,7 +1761,7 @@ def get_all_labels():
"""
rv = [ ]
for i in renpy.game.script.namemap.keys():
for i in renpy.game.script.namemap:
if isinstance(i, basestring):
rv.append(i)
+1 -1
View File
@@ -247,7 +247,7 @@ def process_downloaded_resources():
# Due to search-path dups and derived images (including image-based animations)
# files can't be removed right after actual load
ttl = 60 # remove after 1mn - if your animation is longer than that, use a video
for fullpath in to_unlink.keys():
for fullpath in to_unlink:
delta = time.time() - to_unlink[fullpath]
if delta > ttl:
os.unlink(fullpath)