summaryrefslogtreecommitdiff
path: root/android/mobile-config.py
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-12-10 09:06:35 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-10 09:15:50 +0100
commit7b3fea40032a3542349c688f44ae321397af2c07 (patch)
tree053501911a2df959a6bd8b6e1ad02e1102c37df6 /android/mobile-config.py
parentffffc526e3d6529567694d96a5877d9c63e8e48d (diff)
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
Diffstat (limited to 'android/mobile-config.py')
-rwxr-xr-xandroid/mobile-config.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/android/mobile-config.py b/android/mobile-config.py
index 8b1f44e2c9ec..13085c75b28c 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: