From 253c35c0e0322138176abbfb3825dd85dfeece5c Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 23 Dec 2017 16:56:57 -0500 Subject: Bug 1426963 - Make Bugzilla::User->in_group() use a hash lookup --- Bugzilla/User.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 68a3b8313..dc8f60565 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -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)) { -- cgit v1.2.3-24-g4f1b