]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Thread.pm
Merge remote-tracking branch 'origin/search'
[public-inbox.git] / lib / PublicInbox / Thread.pm
1 # subclass Mail::Thread and use this to workaround a memory leak
2 # Based on the patch in: https://rt.cpan.org/Public/Bug/Display.html?id=22817
3 # License differs from the rest of public-inbox (but is compatible):
4 # This library is free software; you can redistribute it and/or modify
5 # it under the same terms as Perl itself.
6 package PublicInbox::Thread;
7 use strict;
8 use warnings;
9 use base qw(Mail::Thread);
10
11 if ($Mail::Thread::VERSION <= 2.55) {
12         eval q(sub _container_class { 'PublicInbox::Thread::Container' });
13 }
14
15 sub sort_ts {
16         sort {
17                 (eval { $a->topmost->message->header('X-PI-TS') } || 0) <=>
18                 (eval { $b->topmost->message->header('X-PI-TS') } || 0)
19         } @_;
20 }
21
22 sub rsort_ts {
23         sort {
24                 (eval { $b->topmost->message->header('X-PI-TS') } || 0) <=>
25                 (eval { $a->topmost->message->header('X-PI-TS') } || 0)
26         } @_;
27 }
28
29 package PublicInbox::Thread::Container;
30 use strict;
31 use warnings;
32 use base qw(Mail::Thread::Container);
33 use Scalar::Util qw(weaken);
34 sub parent { @_ == 2 ? weaken($_[0]->{parent} = $_[1]) : $_[0]->{parent} }
35
36 1;