While the contents of normal %want hash keys are bounded in
size, %partial can cause more overhead and lead to repeated sort
calls on multi-message fetches. So sort it once and use
arrayrefs to make the data structure more compact.
sub partial_emit ($$$) {
my ($self, $partial, $eml) = @_;
sub partial_emit ($$$) {
my ($self, $partial, $eml) = @_;
- for my $k (sort keys %$partial) {
- my ($cb, @args) = @{$partial->{$k}};
+ for (@$partial) {
+ my ($k, $cb, @args) = @$_;
my ($offset, $len) = splice(@args, -2);
# $cb is partial_body|partial_hdr_get|partial_hdr_not
my $str = $cb->($eml, @args) // '';
my ($offset, $len) = splice(@args, -2);
# $cb is partial_body|partial_hdr_get|partial_hdr_not
my $str = $cb->($eml, @args) // '';
return "$tag BAD param: $att\r\n";
}
}
return "$tag BAD param: $att\r\n";
}
}
- $want{-partial} = \%partial if scalar keys %partial;
+
+ # stabilize partial order for consistency and ease-of-debugging:
+ if (scalar keys %partial) {
+ $want{-partial} = [ map {
+ [ $_, @{$partial{$_}} ]
+ } sort keys %partial ];
+ }
+
my ($beg, $end);
my $msgs = [];
if ($range =~ /\A([0-9]+):([0-9]+)\z/s) {
my ($beg, $end);
my $msgs = [];
if ($range =~ /\A([0-9]+):([0-9]+)\z/s) {