summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-14 01:40:42 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-14 01:40:42 +0100
commitd34b096c49dd432d52a620bd1425781b45763f20 (patch)
tree15d080e32ac6f01a463a063fe7cd279692cc1477 /Bugzilla
parent217beee45f5ba22aea80c8a61a639b55fe53293c (diff)
downloadbugzilla-d34b096c49dd432d52a620bd1425781b45763f20.tar.gz
bugzilla-d34b096c49dd432d52a620bd1425781b45763f20.tar.xz
Bug 552168: Speed up comment display by pre-loading all Bugzilla::User
objects for the comment authors, for the whole list, all at once. r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm1
-rw-r--r--Bugzilla/Comment.pm13
2 files changed, 14 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 4a90c1ce7..d435d5442 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -2719,6 +2719,7 @@ sub comments {
$comment->{count} = $count++;
$comment->{bug} = $self;
}
+ Bugzilla::Comment->preload($self->{'comments'});
}
my @comments = @{ $self->{'comments'} };
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm
index f19c64d78..ba33ba5f3 100644
--- a/Bugzilla/Comment.pm
+++ b/Bugzilla/Comment.pm
@@ -27,6 +27,7 @@ use base qw(Bugzilla::Object);
use Bugzilla::Attachment;
use Bugzilla::Constants;
use Bugzilla::Error;
+use Bugzilla::User;
use Bugzilla::Util;
###############################
@@ -74,6 +75,18 @@ sub update {
return $changes;
}
+# Speeds up displays of comment lists by loading all ->author objects
+# at once for a whole list.
+sub preload {
+ my ($class, $comments) = @_;
+ my %user_ids = map { $_->{who} => 1 } @$comments;
+ my $users = Bugzilla::User->new_from_list([keys %user_ids]);
+ my %user_map = map { $_->id => $_ } @$users;
+ foreach my $comment (@$comments) {
+ $comment->{author} = $user_map{$comment->{who}};
+ }
+}
+
###############################
#### Accessors ######
###############################