]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 499121 - Cache user objects for Bug::GetComments
authorbbaetz%acm.org <>
Fri, 19 Jun 2009 02:08:41 +0000 (02:08 +0000)
committerbbaetz%acm.org <>
Fri, 19 Jun 2009 02:08:41 +0000 (02:08 +0000)
r/a=mkanat

Bugzilla/Bug.pm

index f1fc9c42483ba022240e4968fa7683a7b3d15675..b66ace54f541e341e43da97dda960ba9c4a7487d 100644 (file)
@@ -3043,9 +3043,13 @@ sub GetComments {
     my $sth = $dbh->prepare($query);
     $sth->execute(@args);
 
+    # Cache the users we look up
+    my %users;
+
     while (my $comment_ref = $sth->fetchrow_hashref()) {
         my %comment = %$comment_ref;
-        $comment{'author'} = new Bugzilla::User($comment{'userid'});
+        $users{$comment{'userid'}} ||= new Bugzilla::User($comment{'userid'});
+        $comment{'author'} = $users{$comment{'userid'}};
 
         # If raw data is requested, do not format 'special' comments.
         $comment{'body'} = format_comment(\%comment) unless $raw;