Skip to content

Commit 37cf7f9

Browse files
committed
delete unneeded variable
1 parent 4948503 commit 37cf7f9

File tree

3 files changed

+43
-58
lines changed

3 files changed

+43
-58
lines changed

src/decoders/quoted_printable.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,27 @@ impl<'x> MessageStream<'x> {
312312
None
313313
}
314314
}
315+
316+
/*
317+
* Adapted from Daniel Lemire's source:
318+
* https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp
319+
*
320+
*/
321+
322+
pub static HEX_MAP: &[i8] = &[
323+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
324+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
325+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1,
326+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
327+
11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
328+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
329+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
330+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
331+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
332+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
333+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
334+
];
335+
315336
#[cfg(test)]
316337
mod tests {
317338
use crate::parsers::MessageStream;
@@ -468,23 +489,3 @@ mod tests {
468489
}
469490
}
470491
}
471-
472-
/*
473-
* Adapted from Daniel Lemire's source:
474-
* https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp
475-
*
476-
*/
477-
478-
pub static HEX_MAP: &[i8] = &[
479-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
480-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
481-
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1,
482-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10,
483-
11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
484-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
485-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
486-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
487-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
488-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
489-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
490-
];

src/parsers/message.rs

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ impl MessageParser {
306306
(false, false)
307307
};
308308

309+
if add_to_html {
310+
message.html_body.push(message.parts.len());
311+
}
312+
if add_to_text {
313+
message.text_body.push(message.parts.len());
314+
}
315+
316+
if !is_multipart && !add_to_text && !add_to_html
317+
|| (mime_type == MimeType::Inline || is_multipart)
318+
&& (!add_to_text || !add_to_html)
319+
{
320+
message.attachments.push(message.parts.len());
321+
}
322+
309323
if is_text {
310324
let text = match (
311325
bytes,
@@ -323,46 +337,16 @@ impl MessageParser {
323337
}
324338
(Cow::Borrowed(bytes), None) => String::from_utf8_lossy(bytes),
325339
};
326-
let is_html = mime_type == MimeType::TextHtml;
327340

328-
if add_to_html {
329-
message.html_body.push(message.parts.len());
330-
}
331-
if add_to_text {
332-
message.text_body.push(message.parts.len());
333-
}
334-
335-
if !is_multipart && !(add_to_text || add_to_html)
336-
|| (mime_type == MimeType::Inline || is_multipart)
337-
&& (!add_to_text || !add_to_html)
338-
{
339-
message.attachments.push(message.parts.len());
340-
}
341-
342-
if is_html {
341+
if mime_type == MimeType::TextHtml {
343342
PartType::Html(text)
344343
} else {
345344
PartType::Text(text)
346345
}
346+
} else if !is_inline {
347+
PartType::Binary(bytes)
347348
} else {
348-
if add_to_html {
349-
message.html_body.push(message.parts.len());
350-
}
351-
if add_to_text {
352-
message.text_body.push(message.parts.len());
353-
}
354-
if !is_multipart && !(add_to_text || add_to_html)
355-
|| (mime_type == MimeType::Inline || is_multipart)
356-
&& (!add_to_text || !add_to_html)
357-
{
358-
message.attachments.push(message.parts.len());
359-
}
360-
361-
if !is_inline {
362-
PartType::Binary(bytes)
363-
} else {
364-
PartType::InlineBinary(bytes)
365-
}
349+
PartType::InlineBinary(bytes)
366350
}
367351
} else {
368352
message.attachments.push(message.parts.len());

src/parsers/mime.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ impl<'x> MessageStream<'x> {
134134
self.checkpoint();
135135

136136
match (self.next(), self.peek()) {
137-
(Some(&a), Some(&&b)) if a == b'\r' && b == b'\n' => {
137+
(Some(b'\r'), Some(b'\n')) => {
138138
self.next();
139139
false
140140
}
141-
(Some(&a), Some(&&b)) if a == b'-' && b == b'-' => {
141+
(Some(b'-'), Some(b'-')) => {
142142
self.next();
143143
true
144144
}
145-
(Some(&a), _) if a == b'\n' => false,
146-
(Some(&a), _) if a.is_ascii_whitespace() => {
145+
(Some(b'\n'), _) => false,
146+
(Some(a), _) if a.is_ascii_whitespace() => {
147147
self.skip_crlf();
148148
false
149149
}

0 commit comments

Comments
 (0)