]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Address.pm
watchmaildir: match List-ID case-insensitively
[public-inbox.git] / lib / PublicInbox / Address.pm
1 # Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::Address;
4 use strict;
5 use warnings;
6
7 sub xs_emails {
8         grep { defined } map { $_->address() } parse_email_addresses($_[0])
9 }
10
11 sub xs_names {
12         grep { defined } map {
13                 my $n = $_->name;
14                 my $addr = $_->address;
15                 $n = $_->user if defined($addr) && $n eq $addr;
16                 $n;
17         } parse_email_addresses($_[0]);
18 }
19
20 eval {
21         require Email::Address::XS;
22         Email::Address::XS->import(qw(parse_email_addresses));
23         *emails = \&xs_emails;
24         *names = \&xs_names;
25 };
26
27 if ($@) {
28         require PublicInbox::AddressPP;
29         *emails = \&PublicInbox::AddressPP::emails;
30         *names = \&PublicInbox::AddressPP::names;
31 }
32
33 1;