diff options
author | Eric Wong <e@yhbt.net> | 2020-01-11 06:28:16 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-01-12 21:26:42 +0000 |
commit | 195c40c82e77c73e171f75529b80c7561565d512 (patch) | |
tree | 738c85840311d34629ae46bbc3ceb4cd9e5d8095 /lib/PublicInbox/View.pm | |
parent | 80e819ceebf922ecda684cc8ef0848ddc709a73c (diff) | |
download | public-inbox-195c40c82e77c73e171f75529b80c7561565d512.tar.gz |
We're often iterating through messages while writing to another buffer in our WWW interface, causing memory usage to multiply. Since we know we won't need to keep the MIME object around in some cases, and can tell msg_iter to clobber the on-stack variable while it operates on subparts of multipart messages. With xt/mem-msgview.t switched to multipart from the previous commit, this shows a 13 MB memory reduction on that test.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r-- | lib/PublicInbox/View.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 405da2a9..d88b34da 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -275,7 +275,7 @@ sub index_entry { # scan through all parts, looking for displayable text $ctx->{mhref} = $mhref; $ctx->{rv} = \$rv; - msg_iter($mime, \&add_text_body, $ctx); + msg_iter($mime, \&add_text_body, $ctx, 1); delete $ctx->{rv}; # add the footer @@ -506,12 +506,12 @@ sub thread_html_i { # PublicInbox::WwwStream::getline callback } sub multipart_text_as_html { - my ($mime, $mhref, $ctx) = @_; + my (undef, $mhref, $ctx) = @_; # $mime = $_[0] $ctx->{mhref} = $mhref; $ctx->{rv} = \(my $rv = ''); # scan through all parts, looking for displayable text - msg_iter($mime, \&add_text_body, $ctx); + msg_iter($_[0], \&add_text_body, $ctx, 1); ${delete $ctx->{rv}}; } |