use fnv hash
parent
04ff21a55f
commit
d3b00d19ce
|
@ -21,6 +21,7 @@ nom = "3.2.0"
|
|||
memmap = "*"
|
||||
base64 = "*"
|
||||
crossbeam = "^0.3.0"
|
||||
fnv = "1.0.3"
|
||||
|
||||
[dependencies.ncurses]
|
||||
features = ["wide"]
|
||||
|
|
|
@ -90,10 +90,6 @@ named!(pub attachment<(std::vec::Vec<(&str, &str)>, &[u8])>,
|
|||
pair: pair!(many0!(complete!(header)), take_while!(call!(|_| { true }))) >>
|
||||
( { pair } )));
|
||||
|
||||
/* try chrono parse_from_str with several formats
|
||||
* https://docs.rs/chrono/0.4.0/chrono/struct.DateTime.html#method.parse_from_str
|
||||
*/
|
||||
|
||||
/* Header parsers */
|
||||
|
||||
/* Encoded words
|
||||
|
@ -133,7 +129,7 @@ named!(utf8_token<Vec<u8>>, alt_complete!(
|
|||
call!(utf8_token_quoted_p)));
|
||||
|
||||
named!(utf8_token_list<String>, ws!(do_parse!(
|
||||
list: separated_nonempty_list!(complete!(tag!(" ")), utf8_token) >>
|
||||
list: separated_nonempty_list!(complete!(is_a!(" ")), utf8_token) >>
|
||||
( {
|
||||
let list_len = list.iter().fold(0, |mut acc, x| { acc+=x.len(); acc });
|
||||
let bytes = list.iter().fold(Vec::with_capacity(list_len), |mut acc, x| { acc.append(&mut x.clone()); acc});
|
||||
|
@ -172,6 +168,8 @@ fn test_subject() {
|
|||
assert_eq!((&b""[..], "list.free.de mailing list memberships reminder".to_string()), subject(subject_s).unwrap());
|
||||
let subject_s = "=?UTF-8?B?zp3Orc6/IM+Az4HOv8+Dz4nPgM65zrrPjCDOvM6uzr3Phc68zrEgzrHPhs6v?= =?UTF-8?B?z4fOuM63?=".as_bytes();
|
||||
assert_eq!((&b""[..], "Νέο προσωπικό μήνυμα αφίχθη".to_string()), subject(subject_s).unwrap());
|
||||
let subject_s = "=?utf-8?B?bW9vZGxlOiDOsc69zrHPg866z4zPgM63z4POtyDOv868zqzOtM6xz4Igz4M=?= =?utf-8?B?z4XOts63z4TOrs+DzrXPic69?=".as_bytes();
|
||||
assert_eq!((&b""[..], "moodle: ανασκόπηση ομάδας συζητήσεων".to_string()), subject(subject_s).unwrap());
|
||||
}
|
||||
fn eat_comments(input: &str) -> String {
|
||||
let mut in_comment = false;
|
||||
|
|
|
@ -27,8 +27,10 @@ use mailbox::backends::MailBackend;
|
|||
use mailbox::backends::maildir;
|
||||
use error::Result;
|
||||
|
||||
extern crate fnv;
|
||||
|
||||
use self::fnv::FnvHashMap;
|
||||
use std::option::Option;
|
||||
use std::collections::HashMap;
|
||||
use std;
|
||||
|
||||
type UnixTimestamp = i64;
|
||||
|
@ -133,7 +135,7 @@ impl PartialEq for Thread {
|
|||
}
|
||||
}
|
||||
|
||||
fn build_collection(threads: &mut Vec<Thread>, id_table: &mut HashMap<std::string::String, usize>, collection: &mut [Mail]) -> () {
|
||||
fn build_collection(threads: &mut Vec<Thread>, id_table: &mut FnvHashMap<std::string::String, usize>, collection: &mut [Mail]) -> () {
|
||||
for (i, x) in collection.iter_mut().enumerate() {
|
||||
let x_index; /* x's index in threads */
|
||||
let m_id = x.get_message_id_raw().to_string();
|
||||
|
@ -242,7 +244,7 @@ impl Mailbox {
|
|||
/* a vector to hold thread members */
|
||||
let mut threads: Vec<Thread> = Vec::with_capacity((collection.len() as f64 * 1.2) as usize);
|
||||
/* A hash table of Message IDs */
|
||||
let mut id_table: HashMap<std::string::String, usize> = HashMap::with_capacity(collection.len());
|
||||
let mut id_table: FnvHashMap<std::string::String, usize> = FnvHashMap::with_capacity_and_hasher(collection.len(), Default::default());
|
||||
|
||||
collection.sort_by(|a, b| a.get_date().cmp(&b.get_date()));
|
||||
/* Add each message to id_table and threads, and link them together according to the
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
use mailbox::email::Mail;
|
||||
use mailbox::*;
|
||||
use error::MeliError;
|
||||
use std::error::Error;
|
||||
|
||||
extern crate ncurses;
|
||||
use std::error::Error;
|
||||
|
||||
pub trait Window {
|
||||
fn draw(&mut self) -> ();
|
||||
|
|
Loading…
Reference in New Issue