android/mobile-config.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
New commits: commit 7b3fea40032a3542349c688f44ae321397af2c07 Author: Miklos Vajna <vmik...@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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits