OSDN Git Service

Memorize commit authors to speed up changesets loading.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 21 Feb 2010 14:42:45 +0000 (14:42 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 21 Feb 2010 14:42:45 +0000 (14:42 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3472 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository.rb

index da1168d..dee705c 100644 (file)
@@ -136,6 +136,7 @@ class Repository < ActiveRecord::Base
         end
       end
       @committers = nil
+      @found_committer_users = nil
       true
     else
       false
@@ -146,16 +147,22 @@ class Repository < ActiveRecord::Base
   # It will return nil if the committer is not yet mapped and if no User
   # with the same username or email was found
   def find_committer_user(committer)
-    if committer
+    unless committer.blank?
+      @found_committer_users ||= {}
+      return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
+      
+      user = nil
       c = changesets.find(:first, :conditions => {:committer => committer}, :include => :user)
       if c && c.user
-        c.user
+        user = c.user
       elsif committer.strip =~ /^([^<]+)(<(.*)>)?$/
         username, email = $1.strip, $3
         u = User.find_by_login(username)
         u ||= User.find_by_mail(email) unless email.blank?
-        u
+        user = u
       end
+      @found_committer_users[committer] = user
+      user
     end
   end