]> Sergey Matveev's repositories - public-inbox.git/commitdiff
imapd: don't bother sorting LIST output
authorEric Wong <e@yhbt.net>
Wed, 10 Jun 2020 07:05:16 +0000 (07:05 +0000)
committerEric Wong <e@yhbt.net>
Sat, 13 Jun 2020 07:55:45 +0000 (07:55 +0000)
The sort was unstable on my test instance anyways, and
clients don't seem to mind.  So stop wasting CPU cycles.

lib/PublicInbox/IMAPD.pm
t/imapd.t

index fe50de0f7cdee63295eba919172dc8f07a514e83..09bedf5ca9b42c7b74129a94bab7b50b5df0acc3 100644 (file)
@@ -74,11 +74,6 @@ sub imapd_refresh_finalize {
                        my $u = $_; # capitalize "INBOX" for user-familiarity
                        $u =~ s/\Ainbox(\.|\z)/INBOX$1/i;
                        qq[* LIST (\\Has${no}Children) "." $u\r\n]
-               } sort {
-                       # shortest names first, alphabetically if lengths match
-                       length($a) == length($b) ?
-                               ($a cmp $b) :
-                               (length($a) <=> length($b))
                } keys %$mailboxes
        ];
        $imapd->{pi_config} = $pi_config;
index e3cce2d30f07ee9aa4339e93b475a2a33a755a40..c7e0baaa10b18d3cbfbe5593afebbffccf0fccb8 100644 (file)
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -405,7 +405,9 @@ is($r2->{2}->{'BODY[HEADER.FIELDS (MESSAGE-ID)]'},
        pop @new_list;
        pop @orig_list;
        # TODO: not sure if sort order matters, imapd_refresh_finalize
-       # sorts, for now, but maybe clients don't care...
+       # doesn't sort, hopefully clients don't care...
+       @new_list = sort @new_list;
+       @orig_list = sort @orig_list;
        is_deeply(\@new_list, \@orig_list, 'LIST identical');
 }
 ok($mic->close, 'CLOSE works');