mail
mail copied to clipboard
Improve performance of Message#find_attachment
This is faster because we,
- Don't trigger exceptions for flow control.
- Retrieve each header only once (at most).
The exceptions this was throwing were particularly expensive for us on jruby. This change cut our mail processing time in half for a particular task.
The tests are passing with this change but it's possible that the rescue
s in the previous code were catching other exceptions that will now bubble up. We could add a rescue
to find_attachment_filename
to catch those.
:+1: causing and catching exceptions is super-messy
@jeremy @bf4
@grosser cleaned up the duplication in #find_attachment_filename
. I like to avoid using #send
if possible.
@jeremy @bf4
Is there a benchmark you used that we can run to test against regressions?
@bf4 I don't have anything that's easily extractable, I was profiling an application.
I agree a benchmark suite would be really useful.