chiark / gitweb /
metadata: slightly speed up post_metadata_parse
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 11 Jan 2016 12:25:03 +0000 (13:25 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 11 Mar 2016 13:27:01 +0000 (13:27 +0000)
Iterating over all the fields and checking which are modified is slower
than just iterating over the modified ones.

fdroidserver/metadata.py

index 5d4c0b5ba79bdf5396752e816849890e0b72bd30..0112a0ec1b50451455e342cad634e9e455b7aefc 100644 (file)
@@ -842,17 +842,14 @@ esc_newlines = re.compile(r'\\( |\n)')
 # This function uses __dict__ to be faster
 def post_metadata_parse(app):
 
-    for k, v in app.__dict__.items():
-        if k not in app._modified:
-            continue
+    for k in app._modified:
+        v = app.__dict__[k]
         if type(v) in (float, int):
             app.__dict__[k] = str(v)
 
     for build in app.builds:
-        for k, v in build.__dict__.items():
-
-            if k not in build._modified:
-                continue
+        for k in build._modified:
+            v = build.__dict__[k]
             if type(v) in (float, int):
                 build.__dict__[k] = str(v)
                 continue