remove long startup when merging, due to rexml poor performance
authorGuillaume Cottenceau <gcottenc@gmail.com>
Wed, 24 Dec 2008 14:47:28 +0000 (15:47 +0100)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Wed, 24 Dec 2008 14:47:28 +0000 (15:47 +0100)
TODO
bin/booh-backend

diff --git a/TODO b/TODO
index 696e5a6..18608b8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,7 +10,4 @@
 > about what happened in a particular photo, and that doesn't look very nice
 > as a caption
 
-when you merge current dir, startup may be very slow (many files
-in dir?) without the progressbar moving, we think it's frozen/dead..
-
 properly detect ' in source directory names
index 61bb820..edd8feb 100755 (executable)
@@ -809,13 +809,18 @@ def walk_source_dir
         else
             msg 2, _("Examining %s...") % dir
             entries = Dir.entries(dir).sort
+            #- preprocess all the existing elements, rexml is slow with that
+            optelements = []
+            xmldir.elements.each { |elem|
+                optelements << elem.name + '|' + elem.attributes['filename']
+            }
             #- populate config in case of gen_config, add new files in case of merge_config
             for file in entries
                 if file =~ /['"\[\]]/
                     msg 1, _("Ignoring %s, contains one of forbidden characters: '\"[]") % "#{dir}/#{file}"
                 else
                     type = entry2type(file)
-                    if type && !xmldir.elements["#{type}[@filename='#{utf8(file)}']"]
+                    if type && ! optelements.include?(type + '|' + utf8(file))
                         #- hack: don't run identify (which is slow) if format only contains default %t
                         if $commentsformat && type == 'image' && $commentsformat != '%t'
                             comment = utf8(`identify -format "#{$commentsformat}" '#{dir}/#{file}'`.chomp.sub(/\.$/, ''))