Improve performance of mimetype guessing when we use the file extension.

Review Request #13513 — Created Jan. 31, 2024 and submitted

Information

Review Board
master

Reviewers

A while back we added an escape hatch for mapping certain file
extensions to mimetypes for when mimeparse messes up (specfically with
text/x-rst and text/x-markdown). While I was looking at this code, I
realized that we go through all the trouble of using mimeparse only to
throw away the result. The mimeparse code isn't doing a whole lot, but
it's always better to avoid doing work if we don't need to. This change
swaps those so if we're going to match based on the file extension, we
do that first, and only use mimeparse otherwise.

Ran unit tests.

Summary ID
Improve performance of mimetype guessing when we use the file extension.
A while back we added an escape hatch for mapping certain file extensions to mimetypes for when mimeparse messes up (specfically with `text/x-rst` and text/x-markdown`). While I was looking at this code, I realized that we go through all the trouble of using mimeparse only to throw away the result. The mimeparse code isn't doing a whole lot, but it's always better to avoid doing work if we don't need to. This change swaps those so if we're going to match based on the file extension, we do that first, and only use mimeparse otherwise. Testing Done: Ran unit tests.
447695c90c28c4faa9388bbf51c1d964e61f6f85
maubin
  1. Ship It!
  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-7.x (81a59ca)
Loading...