]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Thread.pm
dead code cleanup
[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 #
4 # Additionally, workaround for a bug where $walk->topmost returns undef:
5 # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913
6 # - https://rt.cpan.org/Ticket/Display.html?id=106498
7 #
8 # License differs from the rest of public-inbox (but is compatible):
9 # This library is free software; you can redistribute it and/or modify
10 # it under the same terms as Perl itself.
11 package PublicInbox::Thread;
12 use strict;
13 use warnings;
14 use base qw(Mail::Thread);
15
16 if ($Mail::Thread::VERSION <= 2.55) {
17         eval q(sub _container_class { 'PublicInbox::Thread::Container' });
18 }
19
20 sub sort_ts {
21         sort {
22                 (eval { $a->topmost->message->header('X-PI-TS') } || 0) <=>
23                 (eval { $b->topmost->message->header('X-PI-TS') } || 0)
24         } @_;
25 }
26
27 package PublicInbox::Thread::Container;
28 use strict;
29 use warnings;
30 use base qw(Mail::Thread::Container);
31 use Scalar::Util qw(weaken);
32 sub parent { @_ == 2 ? weaken($_[0]->{parent} = $_[1]) : $_[0]->{parent} }
33
34 sub topmost {
35         $_[0]->SUPER::topmost || PublicInbox::Thread::CPANRTBug106498->new;
36 }
37
38 # ref:
39 # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913
40 # - https://rt.cpan.org/Ticket/Display.html?id=106498
41 package PublicInbox::Thread::CPANRTBug106498;
42 use strict;
43 use warnings;
44
45 sub new { bless {}, $_[0] }
46
47 sub simple_subject {}
48
49 1;