]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1426963 - Make Bugzilla::User->in_group() use a hash lookup
authorDylan William Hardison <dylan@hardison.net>
Sat, 23 Dec 2017 21:56:57 +0000 (16:56 -0500)
committerGitHub <noreply@github.com>
Sat, 23 Dec 2017 21:56:57 +0000 (16:56 -0500)
Bugzilla/User.pm

index 68a3b83130f94d9f837dc85d082fa2e5bef8f8e8..dc8f6056514a644f6f0af53ea60648a120bac93a 100644 (file)
@@ -1316,7 +1316,9 @@ sub bless_groups {
 sub in_group {
     my ($self, $group, $product_id) = @_;
     $group = $group->name if blessed $group;
-    if (scalar grep($_->name eq $group, @{ $self->groups })) {
+    $self->{in_group} //= { map { $_->name  => $_ } @{ $self->groups } };
+
+    if ($self->{in_group}{$group}) {
         return 1;
     }
     elsif ($product_id && detaint_natural($product_id)) {