Use parse_headers rather than parsing body (#1090)

Looking at the internals, this should make almost no difference in
performance, but anyway...
This commit is contained in:
Charlie Marsh 2024-01-25 00:41:21 -08:00 committed by GitHub
parent b5cfd3616f
commit 036b7e5f43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,8 +75,7 @@ pub enum Error {
impl Metadata21 {
/// Parse distribution metadata from metadata bytes
pub fn parse(content: &[u8]) -> Result<Self, Error> {
let msg = mailparse::parse_mail(content)?;
let headers = msg.get_headers();
let (headers, _) = mailparse::parse_headers(content)?;
let get_first_value = |name| {
headers.get_first_header(name).and_then(|header| {