a split is about 20% faster than doing a regex match here, for
a typical email address and domain
(benchmarked with Benchmark::cmpthese)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
sub who_match {
my ($self, $addr) = @_;
- $addr =~ m/^.+@(.+)$/;
+ my @parts = split('@', $addr);
- return undef if !defined($1);
+ return undef if scalar(@parts) < 2;
- return (lc ($1) eq lc ($self->address));
+ my $domain = $parts[-1]; # last element
+ return lc $domain eq lc $self->{address};
}
sub short_desc {