[Libreoffice-commits] core.git: android/mobile-config.py

Miklos Vajna vmiklos at collabora.co.uk
Wed Dec 10 00:26:24 PST 2014


 android/mobile-config.py |   29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

New commits:
commit 7b3fea40032a3542349c688f44ae321397af2c07
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Dec 10 09:06:35 2014 +0100

    android: speed up mobile-config.py
    
    Make it O(N) instead of O(N^2), where N is the number of children of the
    root note.
    
    3.596s -> 0.960s for main.xcd
    
    Change-Id: I1b9904a377603cd57f84636c873ed2b752abd101

diff --git a/android/mobile-config.py b/android/mobile-config.py
index 8b1f44e..13085c7 100755
--- a/android/mobile-config.py
+++ b/android/mobile-config.py
@@ -57,21 +57,20 @@ if __name__ == '__main__':
         total += len(ET.tostring(child))
 
     saved = 0
-    restarted = True
+    to_remove = []
 
-    while restarted:
-        restarted = False
-        for child in root:
-            section = child.attrib['{http://openoffice.org/2001/registry}name']
-            package = child.attrib['{http://openoffice.org/2001/registry}package']
-            size = len(ET.tostring(child));
-            key = '%s/%s' % (package, section)
-            if key in main_xcd_discard:
-                root.remove(child)
-                print 'removed %s - saving %d' % (key, size)
-                saved = saved + size
-                restarted = True
-                break
+    for child in root:
+        section = child.attrib['{http://openoffice.org/2001/registry}name']
+        package = child.attrib['{http://openoffice.org/2001/registry}package']
+        size = len(ET.tostring(child));
+        key = '%s/%s' % (package, section)
+        if key in main_xcd_discard:
+            print 'removed %s - saving %d' % (key, size)
+            saved = saved + size
+            to_remove.append(child)
+
+    for child in to_remove:
+        root.remove(child)
 
     print "saved %d of %d bytes: %2.f%%" % (saved, total, saved*100.0/total)
 
@@ -82,3 +81,5 @@ if __name__ == '__main__':
     root.set('xmlns:oor', 'http://openoffice.org/2001/registry')
 
     tree.write(sys.argv[2], 'UTF-8', True)
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list