<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -136,7 +136,7 @@ module Redcar
       re = make_regex(text)
 
       score_match_pairs = []
-      max = 10000000
+      cutoff = 10000000
 
       results = files.each do |fn| 
         unless File.directory?(fn)
@@ -150,12 +150,14 @@ module Redcar
 		            diffs += cs[i] - cs[i-1]
 		          end
 		        end
+						# lower score is better
             score = (cs[0] + diffs)*100 + bit.last.length
-            if score &lt; max
+            if score &lt; cutoff
               score_match_pairs &lt;&lt; [score, fn]
               score_match_pairs.sort!
               if score_match_pairs.length == MAX_ENTRIES
-                max = score_match_pairs.last.first
+                cutoff = score_match_pairs.last.first
+                score_match_pairs.pop
               end
             end
       		end</diff>
      <filename>plugins/project/dialogs/find_file_dialog.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,22 @@
 
 def find_files(text, directories)
   files = []
+  s = Time.now
   directories.each do |dir|
     files += Dir[File.expand_path(dir + &quot;/**/*&quot;)]
   end
-  
+  puts &quot;find files took: #{Time.now - s}&quot;
   re = make_regex(text)
   
   score_match_pairs = []
-  max = 10000000
-  
+  cutoff = 10000000
+  s = Time.now
+  count = 0
   results = files.each do |fn| 
     unless File.directory?(fn)
       bit = fn.split(&quot;/&quot;)
       if m = bit.last.match(re)
+        count += 1
         cs = []
         diffs = 0
         m.captures.each_with_index do |_, i|
@@ -23,17 +26,21 @@ def find_files(text, directories)
           end
         end
         score = (cs[0] + diffs)*100 + bit.last.length
-        if score &lt; max
+        if score &lt; cutoff
           score_match_pairs &lt;&lt; [score, fn]
           score_match_pairs.sort!
-          if score_match_pairs.length == 20
-            max = score_match_pairs.last.first
+          if score_match_pairs.length == 21
+            cutoff = score_match_pairs.last.first
+            score_match_pairs.pop
           end
         end
   		end
 		end
 	end
-  score_match_pairs.map {|a| a.last }
+	puts count
+  r = score_match_pairs.map {|a| a.last }
+  puts &quot;score files took: #{Time.now - s}&quot;
+  r
 end
 
 def make_regex(text)
@@ -42,10 +49,10 @@ def make_regex(text)
 end
 
 s = Time.now
-result = find_files(&quot;t&quot;, [&quot;/home/dan/projects/skweb/&quot;])
+result = find_files(&quot;test&quot;, [&quot;/home/dan/redcar/redcar/&quot;])
 puts &quot;took #{Time.now - s}s&quot;
-result.each do |file|
-  # puts file
-  
-end
+# result.each do |file|
+#   # puts file
+#   
+# end
   </diff>
      <filename>scratchpad/test_fuzzy.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>32a48fe81332fd0f16ee2a1a2cb5e4ea031ab35c</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Lucraft</name>
    <email>dan@fluentradical.com</email>
  </author>
  <url>http://github.com/danlucraft/redcar/commit/f1a95a5e03d3735cdc212203e80a11c5edb417c3</url>
  <id>f1a95a5e03d3735cdc212203e80a11c5edb417c3</id>
  <committed-date>2009-05-09T23:35:00-07:00</committed-date>
  <authored-date>2009-05-09T23:33:06-07:00</authored-date>
  <message>Much improved Fuzzy finder performance</message>
  <tree>dba92aab91f3031c9f341df7233319ef70bb433b</tree>
  <committer>
    <name>Daniel Lucraft</name>
    <email>dan@fluentradical.com</email>
  </committer>
</commit>
