From eb701695f71d6e62f5f11b85d3b367494a23c48b Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 10 May 2020 21:14:49 +0300 Subject: [PATCH] Remove fnv crate --- Cargo.lock | 2 - Cargo.toml | 1 - melib/Cargo.toml | 1 - melib/src/addressbook.rs | 20 ++++---- melib/src/addressbook/vcard.rs | 8 +-- melib/src/backends.rs | 12 ++--- melib/src/backends/imap.rs | 29 +++++------ melib/src/backends/imap/connection.rs | 8 ++- melib/src/backends/imap/watch.rs | 2 +- melib/src/backends/jmap.rs | 15 +++--- melib/src/backends/jmap/connection.rs | 2 +- melib/src/backends/jmap/protocol.rs | 3 +- melib/src/backends/maildir/backend.rs | 40 +++++++-------- melib/src/backends/mbox.rs | 10 ++-- melib/src/backends/notmuch.rs | 17 ++++--- melib/src/collection.rs | 30 +++++------ melib/src/email.rs | 8 +-- melib/src/email/compose.rs | 10 ++-- melib/src/lib.rs | 1 - melib/src/thread.rs | 53 +++++++++----------- melib/src/thread/iterators.rs | 6 +-- src/bin.rs | 1 - src/components.rs | 6 +-- src/components/contacts.rs | 4 +- src/components/mail/listing.rs | 3 +- src/components/mail/listing/compact.rs | 16 +++--- src/components/mail/listing/conversations.rs | 16 +++--- src/components/mail/listing/plain.rs | 20 ++++---- src/components/mail/listing/thread.rs | 6 +-- src/components/utilities.rs | 7 ++- src/components/utilities/widgets.rs | 10 ++-- src/conf/accounts.rs | 16 +++--- src/conf/shortcuts.rs | 4 +- src/mailcap.rs | 4 +- src/managesieve.rs | 1 - src/plugins/backend.rs | 8 +-- src/state.rs | 6 +-- src/workers.rs | 14 +++--- 38 files changed, 203 insertions(+), 217 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0d256814..25026cbfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -685,7 +685,6 @@ dependencies = [ "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "linkify 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "melib 0.5.0", @@ -720,7 +719,6 @@ dependencies = [ "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 01ee2d4f0..92ca8ca30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ serde = "1.0.71" serde_derive = "1.0.71" serde_json = "1.0" toml = "0.5.3" -fnv = "1.0.3" # >:c linkify = "0.3.1" # >:c xdg-utils = "0.3.0" nom = "3.2.0" diff --git a/melib/Cargo.toml b/melib/Cargo.toml index e7a46c7ca..e400e25d5 100644 --- a/melib/Cargo.toml +++ b/melib/Cargo.toml @@ -22,7 +22,6 @@ bitflags = "1.0" crossbeam = "0.7.2" data-encoding = "2.1.1" encoding = "0.2.33" -fnv = "1.0.3" memmap = { version = "0.5.2", optional = true } nom = "3.2.0" notify = { version = "4.0.1", optional = true } diff --git a/melib/src/addressbook.rs b/melib/src/addressbook.rs index 3b5920907..3ce2fefe6 100644 --- a/melib/src/addressbook.rs +++ b/melib/src/addressbook.rs @@ -23,7 +23,7 @@ pub mod vcard; use crate::datetime::{self, UnixTimestamp}; -use fnv::FnvHashMap; +use std::collections::HashMap; use uuid::Uuid; use std::ops::Deref; @@ -61,7 +61,7 @@ pub struct AddressBook { display_name: String, created: UnixTimestamp, last_edited: UnixTimestamp, - pub cards: FnvHashMap, + pub cards: HashMap, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] @@ -80,7 +80,7 @@ pub struct Card { color: u8, last_edited: UnixTimestamp, - extra_properties: FnvHashMap, + extra_properties: HashMap, /// If true, we can't make any changes because we do not manage this resource. external_resource: bool, @@ -92,7 +92,7 @@ impl AddressBook { display_name, created: datetime::now(), last_edited: datetime::now(), - cards: FnvHashMap::default(), + cards: HashMap::default(), } } @@ -132,9 +132,9 @@ impl AddressBook { } impl Deref for AddressBook { - type Target = FnvHashMap; + type Target = HashMap; - fn deref(&self) -> &FnvHashMap { + fn deref(&self) -> &HashMap { &self.cards } } @@ -156,7 +156,7 @@ impl Card { last_edited: datetime::now(), external_resource: false, - extra_properties: FnvHashMap::default(), + extra_properties: HashMap::default(), color: 0, } } @@ -229,7 +229,7 @@ impl Card { self.extra_properties.get(key).map(String::as_str) } - pub fn extra_properties(&self) -> &FnvHashMap { + pub fn extra_properties(&self) -> &HashMap { &self.extra_properties } @@ -242,8 +242,8 @@ impl Card { } } -impl From> for Card { - fn from(mut map: FnvHashMap) -> Card { +impl From> for Card { + fn from(mut map: HashMap) -> Card { let mut card = Card::new(); if let Some(val) = map.remove("TITLE") { card.title = val; diff --git a/melib/src/addressbook/vcard.rs b/melib/src/addressbook/vcard.rs index ac06215cf..7999dbfe6 100644 --- a/melib/src/addressbook/vcard.rs +++ b/melib/src/addressbook/vcard.rs @@ -23,7 +23,7 @@ use super::*; use crate::error::{MeliError, Result}; use crate::parsec::{match_literal_anycase, one_or_more, peek, prefix, take_until, Parser}; -use fnv::FnvHashMap; +use std::collections::HashMap; use std::convert::TryInto; /* Supported vcard versions */ @@ -50,14 +50,14 @@ static FOOTER: &'static str = "END:VCARD\r\n"; #[derive(Debug)] pub struct VCard( - fnv::FnvHashMap, + HashMap, std::marker::PhantomData<*const T>, ); impl VCard { pub fn new_v4() -> VCard { VCard( - FnvHashMap::default(), + HashMap::default(), std::marker::PhantomData::<*const VCardVersion4>, ) } @@ -78,7 +78,7 @@ impl CardDeserializer { &input[HEADER.len()..input.len() - FOOTER.len()] }; - let mut ret = FnvHashMap::default(); + let mut ret = HashMap::default(); enum Stage { Group, diff --git a/melib/src/backends.rs b/melib/src/backends.rs index 71ac51860..f79e897f0 100644 --- a/melib/src/backends.rs +++ b/melib/src/backends.rs @@ -64,8 +64,8 @@ use std::fmt::Debug; use std::ops::Deref; use std::sync::{Arc, RwLock}; -use fnv::FnvHashMap; use std; +use std::collections::HashMap; #[macro_export] macro_rules! get_path_hash { @@ -88,7 +88,7 @@ pub type BackendCreator = Box< /// A hashmap containing all available mail backends. /// An abstraction over any available backends. pub struct Backends { - map: FnvHashMap, + map: HashMap, } pub struct Backend { @@ -111,7 +111,7 @@ pub const NOTMUCH_ERROR_MSG: &'static str = "this version of meli is not compile impl Backends { pub fn new() -> Self { let mut b = Backends { - map: FnvHashMap::with_capacity_and_hasher(1, Default::default()), + map: HashMap::with_capacity_and_hasher(1, Default::default()), }; #[cfg(feature = "maildir_backend")] { @@ -284,7 +284,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { sender: RefreshEventConsumer, work_context: WorkContext, ) -> Result; - fn mailboxes(&self) -> Result>; + fn mailboxes(&self) -> Result>; fn operation(&self, hash: EnvelopeHash) -> Box; fn save(&self, bytes: &[u8], mailbox: &str, flags: Option) -> Result<()>; @@ -303,14 +303,14 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync { fn create_mailbox( &mut self, _path: String, - ) -> Result<(MailboxHash, FnvHashMap)> { + ) -> Result<(MailboxHash, HashMap)> { Err(MeliError::new("Unimplemented.")) } fn delete_mailbox( &mut self, _mailbox_hash: MailboxHash, - ) -> Result> { + ) -> Result> { Err(MeliError::new("Unimplemented.")) } diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs index eedb7fa07..e9b0dea33 100644 --- a/melib/src/backends/imap.rs +++ b/melib/src/backends/imap.rs @@ -43,8 +43,8 @@ use crate::backends::{BackendMailbox, MailBackend, Mailbox, RefreshEventConsumer use crate::conf::AccountSettings; use crate::email::*; use crate::error::{MeliError, Result}; -use fnv::{FnvHashMap, FnvHashSet}; use std::collections::{hash_map::DefaultHasher, BTreeMap}; +use std::collections::{HashMap, HashSet}; use std::hash::Hasher; use std::str::FromStr; use std::sync::{Arc, Mutex, RwLock}; @@ -87,7 +87,7 @@ impl std::ops::Deref for IsSubscribedFn { &self.0 } } -type Capabilities = FnvHashSet>; +type Capabilities = HashSet>; #[macro_export] macro_rules! get_conf_val { @@ -120,11 +120,11 @@ macro_rules! get_conf_val { #[derive(Debug)] pub struct UIDStore { - uidvalidity: Arc>>, - hash_index: Arc>>, - uid_index: Arc>>, + uidvalidity: Arc>>, + hash_index: Arc>>, + uid_index: Arc>>, - byte_cache: Arc>>, + byte_cache: Arc>>, } #[derive(Debug)] pub struct ImapType { @@ -137,7 +137,7 @@ pub struct ImapType { can_create_flags: Arc>, tag_index: Arc>>, - mailboxes: Arc>>, + mailboxes: Arc>>, } #[inline(always)] @@ -407,7 +407,7 @@ impl MailBackend for ImapType { Ok(handle.thread().id()) } - fn mailboxes(&self) -> Result> { + fn mailboxes(&self) -> Result> { { let mailboxes = self.mailboxes.read().unwrap(); if !mailboxes.is_empty() { @@ -420,10 +420,7 @@ impl MailBackend for ImapType { let mut mailboxes = self.mailboxes.write()?; *mailboxes = ImapType::imap_mailboxes(&self.connection)?; mailboxes.retain(|_, f| (self.is_subscribed)(f.path())); - let keys = mailboxes - .keys() - .cloned() - .collect::>(); + let keys = mailboxes.keys().cloned().collect::>(); let mut uid_lock = self.uid_store.uidvalidity.lock().unwrap(); for f in mailboxes.values_mut() { uid_lock.entry(f.hash()).or_default(); @@ -512,7 +509,7 @@ impl MailBackend for ImapType { fn create_mailbox( &mut self, mut path: String, - ) -> Result<(MailboxHash, FnvHashMap)> { + ) -> Result<(MailboxHash, HashMap)> { /* Must transform path to something the IMAP server will accept * * Each root mailbox has a hierarchy delimeter reported by the LIST entry. All paths @@ -566,7 +563,7 @@ impl MailBackend for ImapType { fn delete_mailbox( &mut self, mailbox_hash: MailboxHash, - ) -> Result> { + ) -> Result> { let mut mailboxes = self.mailboxes.write().unwrap(); let permissions = mailboxes[&mailbox_hash].permissions(); if !permissions.delete_mailbox { @@ -939,8 +936,8 @@ impl ImapType { pub fn imap_mailboxes( connection: &Arc>, - ) -> Result> { - let mut mailboxes: FnvHashMap = Default::default(); + ) -> Result> { + let mut mailboxes: HashMap = Default::default(); let mut res = String::with_capacity(8 * 1024); let mut conn = try_lock(&connection)?; conn.send_command(b"LIST \"\" \"*\"")?; diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs index 31246b50b..570abaf10 100644 --- a/melib/src/backends/imap/connection.rs +++ b/melib/src/backends/imap/connection.rs @@ -25,8 +25,8 @@ use crate::error::*; use std::io::Read; use std::io::Write; extern crate native_tls; -use fnv::FnvHashSet; use native_tls::TlsConnector; +use std::collections::HashSet; use std::iter::FromIterator; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; @@ -241,9 +241,7 @@ impl ImapStream { capabilities = protocol_parser::capabilities(l.as_bytes()) .to_full_result() .map(|capabilities| { - FnvHashSet::from_iter( - capabilities.into_iter().map(|s: &[u8]| s.to_vec()), - ) + HashSet::from_iter(capabilities.into_iter().map(|s: &[u8]| s.to_vec())) }) .ok(); } @@ -270,7 +268,7 @@ impl ImapStream { ret.send_command(b"CAPABILITY")?; ret.read_response(&mut res).unwrap(); let capabilities = protocol_parser::capabilities(res.as_bytes()).to_full_result()?; - let capabilities = FnvHashSet::from_iter(capabilities.into_iter().map(|s| s.to_vec())); + let capabilities = HashSet::from_iter(capabilities.into_iter().map(|s| s.to_vec())); Ok((capabilities, ret)) } else { let capabilities = capabilities.unwrap(); diff --git a/melib/src/backends/imap/watch.rs b/melib/src/backends/imap/watch.rs index 685fc17a2..050b4fb82 100644 --- a/melib/src/backends/imap/watch.rs +++ b/melib/src/backends/imap/watch.rs @@ -28,7 +28,7 @@ pub struct ImapWatchKit { pub is_online: Arc)>>, pub main_conn: Arc>, pub uid_store: Arc, - pub mailboxes: Arc>>, + pub mailboxes: Arc>>, pub sender: RefreshEventConsumer, pub work_context: WorkContext, pub tag_index: Arc>>, diff --git a/melib/src/backends/jmap.rs b/melib/src/backends/jmap.rs index 32d6df9d3..774b2d0c9 100644 --- a/melib/src/backends/jmap.rs +++ b/melib/src/backends/jmap.rs @@ -26,9 +26,8 @@ use crate::backends::{BackendMailbox, MailBackend, Mailbox, RefreshEventConsumer use crate::conf::AccountSettings; use crate::email::*; use crate::error::{MeliError, Result}; -use fnv::FnvHashMap; use reqwest::blocking::Client; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; use std::str::FromStr; use std::sync::{Arc, Mutex, RwLock}; use std::time::Instant; @@ -175,9 +174,9 @@ macro_rules! get_conf_val { #[derive(Debug, Default)] pub struct Store { - byte_cache: FnvHashMap, - id_store: FnvHashMap, - blob_id_store: FnvHashMap, + byte_cache: HashMap, + id_store: HashMap, + blob_id_store: HashMap, } #[derive(Debug)] @@ -189,7 +188,7 @@ pub struct JmapType { connection: Arc, store: Arc>, tag_index: Arc>>, - mailboxes: Arc>>, + mailboxes: Arc>>, } impl MailBackend for JmapType { @@ -239,7 +238,7 @@ impl MailBackend for JmapType { Err(MeliError::from("JMAP watch for updates is unimplemented")) } - fn mailboxes(&self) -> Result> { + fn mailboxes(&self) -> Result> { if self.mailboxes.read().unwrap().is_empty() { let mailboxes = std::dbg!(protocol::get_mailboxes(&self.connection))?; *self.mailboxes.write().unwrap() = mailboxes; @@ -291,7 +290,7 @@ impl JmapType { connection: Arc::new(JmapConnection::new(&server_conf, online.clone())?), store: Arc::new(RwLock::new(Store::default())), tag_index: Arc::new(RwLock::new(Default::default())), - mailboxes: Arc::new(RwLock::new(FnvHashMap::default())), + mailboxes: Arc::new(RwLock::new(HashMap::default())), account_name: s.name.clone(), online, is_subscribed: Arc::new(IsSubscribedFn(is_subscribed)), diff --git a/melib/src/backends/jmap/connection.rs b/melib/src/backends/jmap/connection.rs index ecd48905a..110d10de4 100644 --- a/melib/src/backends/jmap/connection.rs +++ b/melib/src/backends/jmap/connection.rs @@ -29,7 +29,7 @@ pub struct JmapConnection { pub online_status: Arc)>>, pub server_conf: JmapServerConf, pub account_id: Arc>, - pub method_call_states: Arc>>, + pub method_call_states: Arc>>, } impl JmapConnection { diff --git a/melib/src/backends/jmap/protocol.rs b/melib/src/backends/jmap/protocol.rs index 32ba2ed29..1693723ee 100644 --- a/melib/src/backends/jmap/protocol.rs +++ b/melib/src/backends/jmap/protocol.rs @@ -25,6 +25,7 @@ use serde::Serialize; use serde_json::{json, Value}; use smallvec::SmallVec; use std::collections::hash_map::DefaultHasher; +use std::collections::HashMap; use std::convert::TryFrom; use std::hash::{Hash, Hasher}; @@ -94,7 +95,7 @@ impl Request { } } -pub fn get_mailboxes(conn: &JmapConnection) -> Result> { +pub fn get_mailboxes(conn: &JmapConnection) -> Result> { let seq = get_request_no!(conn.request_no); let res = conn .client diff --git a/melib/src/backends/maildir/backend.rs b/melib/src/backends/maildir/backend.rs index 210669bf2..894a7847e 100644 --- a/melib/src/backends/maildir/backend.rs +++ b/melib/src/backends/maildir/backend.rs @@ -34,10 +34,10 @@ extern crate notify; use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use std::time::Duration; -use fnv::{FnvHashMap, FnvHashSet, FnvHasher}; +use std::collections::{HashMap, HashSet, hash_map::DefaultHasher}; use std::ffi::OsStr; use std::fs; -use std::hash::{Hash, Hasher}; +use std::hash::{Hasher, Hash}; use std::io::{self, Read, Write}; use std::ops::{Deref, DerefMut}; use std::os::unix::fs::PermissionsExt; @@ -87,31 +87,31 @@ impl From for MaildirPath { #[derive(Debug, Default)] pub struct HashIndex { - index: FnvHashMap, + index: HashMap, hash: MailboxHash, } impl Deref for HashIndex { - type Target = FnvHashMap; - fn deref(&self) -> &FnvHashMap { + type Target = HashMap; + fn deref(&self) -> &HashMap { &self.index } } impl DerefMut for HashIndex { - fn deref_mut(&mut self) -> &mut FnvHashMap { + fn deref_mut(&mut self) -> &mut HashMap { &mut self.index } } -pub type HashIndexes = Arc>>; +pub type HashIndexes = Arc>>; /// Maildir backend https://cr.yp.to/proto/maildir.html #[derive(Debug)] pub struct MaildirType { name: String, - mailboxes: FnvHashMap, - mailbox_index: Arc>>, + mailboxes: HashMap, + mailbox_index: Arc>>, hash_indexes: HashIndexes, path: PathBuf, } @@ -150,11 +150,11 @@ pub(super) fn get_file_hash(file: &Path) -> EnvelopeHash { let mut f = fs::File::open(&file).unwrap_or_else(|_| panic!("Can't open {}", file.display())); f.read_to_end(&mut buf) .unwrap_or_else(|_| panic!("Can't read {}", file.display())); - let mut hasher = FnvHasher::default(); + let mut hasher = DefaultHasher::default(); hasher.write(&buf); hasher.finish() */ - let mut hasher = FnvHasher::default(); + let mut hasher = DefaultHasher::default(); file.hash(&mut hasher); hasher.finish() } @@ -181,7 +181,7 @@ impl MailBackend for MaildirType { Ok(()) } - fn mailboxes(&self) -> Result> { + fn mailboxes(&self) -> Result> { Ok(self .mailboxes .iter() @@ -238,7 +238,7 @@ impl MailBackend for MaildirType { let mut current_hashes = { let mut map = map.lock().unwrap(); let map = map.entry(mailbox_hash).or_default(); - map.keys().cloned().collect::>() + map.keys().cloned().collect::>() }; for file in files { let hash = get_file_hash(&file); @@ -324,7 +324,7 @@ impl MailBackend for MaildirType { .mailboxes .iter() .map(|(&k, v)| (k, (v.unseen.clone(), v.total.clone()))) - .collect::>, Arc>)>>(); + .collect::>, Arc>)>>(); let handle = thread::Builder::new() .name("mailbox watch".to_string()) .spawn(move || { @@ -655,7 +655,7 @@ impl MailBackend for MaildirType { fn create_mailbox( &mut self, new_path: String, - ) -> Result<(MailboxHash, FnvHashMap)> { + ) -> Result<(MailboxHash, HashMap)> { let mut path = self.path.clone(); path.push(&new_path); if !path.starts_with(&self.path) { @@ -700,7 +700,7 @@ impl MailBackend for MaildirType { fn delete_mailbox( &mut self, _mailbox_hash: MailboxHash, - ) -> Result> { + ) -> Result> { Err(MeliError::new("Unimplemented.")) } @@ -726,9 +726,9 @@ impl MaildirType { settings: &AccountSettings, is_subscribed: Box bool>, ) -> Result> { - let mut mailboxes: FnvHashMap = Default::default(); + let mut mailboxes: HashMap = Default::default(); fn recurse_mailboxes>( - mailboxes: &mut FnvHashMap, + mailboxes: &mut HashMap, settings: &AccountSettings, p: P, ) -> Result> { @@ -820,12 +820,12 @@ impl MaildirType { } let mut hash_indexes = - FnvHashMap::with_capacity_and_hasher(mailboxes.len(), Default::default()); + HashMap::with_capacity_and_hasher(mailboxes.len(), Default::default()); for &fh in mailboxes.keys() { hash_indexes.insert( fh, HashIndex { - index: FnvHashMap::with_capacity_and_hasher(0, Default::default()), + index: HashMap::with_capacity_and_hasher(0, Default::default()), hash: fh, }, ); diff --git a/melib/src/backends/mbox.rs b/melib/src/backends/mbox.rs index c652983bf..599b5a9f6 100644 --- a/melib/src/backends/mbox.rs +++ b/melib/src/backends/mbox.rs @@ -36,12 +36,12 @@ use crate::email::*; use crate::error::{MeliError, Result}; use crate::get_path_hash; use crate::shellexpand::ShellExpandTrait; -use fnv::FnvHashMap; use libc; use memmap::{Mmap, Protection}; use nom::{IResult, Needed}; extern crate notify; use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; +use std::collections::HashMap; use std::fs::File; use std::io::BufReader; use std::io::Read; @@ -269,7 +269,7 @@ impl BackendOp for MboxOp { } pub fn mbox_parse( - index: Arc>>, + index: Arc>>, input: &[u8], file_offset: usize, ) -> IResult<&[u8], Vec> { @@ -387,8 +387,8 @@ pub fn mbox_parse( #[derive(Debug, Default)] pub struct MboxType { path: PathBuf, - index: Arc>>, - mailboxes: Arc>>, + index: Arc>>, + mailboxes: Arc>>, } impl MailBackend for MboxType { @@ -588,7 +588,7 @@ impl MailBackend for MboxType { })?; Ok(handle.thread().id()) } - fn mailboxes(&self) -> Result> { + fn mailboxes(&self) -> Result> { Ok(self .mailboxes .lock() diff --git a/melib/src/backends/notmuch.rs b/melib/src/backends/notmuch.rs index 27e43c4f4..0d7513f31 100644 --- a/melib/src/backends/notmuch.rs +++ b/melib/src/backends/notmuch.rs @@ -29,10 +29,11 @@ use crate::conf::AccountSettings; use crate::email::{Envelope, EnvelopeHash, Flag}; use crate::error::{MeliError, Result}; use crate::shellexpand::ShellExpandTrait; -use fnv::FnvHashMap; use smallvec::SmallVec; -use std::collections::hash_map::DefaultHasher; -use std::collections::BTreeMap; +use std::collections::{ + hash_map::{DefaultHasher, HashMap}, + BTreeMap, +}; use std::error::Error; use std::ffi::{CStr, CString, OsStr}; use std::hash::{Hash, Hasher}; @@ -104,8 +105,8 @@ impl Drop for DbConnection { pub struct NotmuchDb { lib: Arc, revision_uuid: Arc>, - mailboxes: Arc>>, - index: Arc>>, + mailboxes: Arc>>, + index: Arc>>, tag_index: Arc>>, path: PathBuf, save_messages_to: Option, @@ -199,7 +200,7 @@ impl NotmuchDb { ))); } - let mut mailboxes = FnvHashMap::default(); + let mut mailboxes = HashMap::default(); for (k, f) in s.mailboxes.iter() { if let Some(query_str) = f.extra.get("query") { let hash = { @@ -490,7 +491,7 @@ impl MailBackend for NotmuchDb { })?; Ok(handle.thread().id()) } - fn mailboxes(&self) -> Result> { + fn mailboxes(&self) -> Result> { Ok(self .mailboxes .read() @@ -533,7 +534,7 @@ impl MailBackend for NotmuchDb { #[derive(Debug)] struct NotmuchOp { hash: EnvelopeHash, - index: Arc>>, + index: Arc>>, tag_index: Arc>>, database: Arc, bytes: Option, diff --git a/melib/src/collection.rs b/melib/src/collection.rs index ccb2c0cae..308412970 100644 --- a/melib/src/collection.rs +++ b/melib/src/collection.rs @@ -27,10 +27,10 @@ use std::collections::BTreeMap; use std::ops::{Deref, DerefMut}; use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}; -use fnv::{FnvHashMap, FnvHashSet}; +use std::collections::{HashMap, HashSet}; pub struct EnvelopeRef<'g> { - guard: RwLockReadGuard<'g, FnvHashMap>, + guard: RwLockReadGuard<'g, HashMap>, env_hash: EnvelopeHash, } @@ -43,7 +43,7 @@ impl Deref for EnvelopeRef<'_> { } pub struct EnvelopeRefMut<'g> { - guard: RwLockWriteGuard<'g, FnvHashMap>, + guard: RwLockWriteGuard<'g, HashMap>, env_hash: EnvelopeHash, } @@ -63,13 +63,13 @@ impl DerefMut for EnvelopeRefMut<'_> { #[derive(Debug, Clone, Deserialize, Default, Serialize)] pub struct Collection { - pub envelopes: Arc>>, - message_ids: FnvHashMap, EnvelopeHash>, + pub envelopes: Arc>>, + message_ids: HashMap, EnvelopeHash>, date_index: BTreeMap, subject_index: Option>, - pub threads: FnvHashMap, + pub threads: HashMap, sent_mailbox: Option, - pub mailboxes: FnvHashMap>, + pub mailboxes: HashMap>, } impl Drop for Collection { @@ -93,17 +93,17 @@ impl Drop for Collection { } impl Collection { - pub fn new(envelopes: FnvHashMap) -> Collection { + pub fn new(envelopes: HashMap) -> Collection { let date_index = BTreeMap::new(); let subject_index = None; - let message_ids = FnvHashMap::with_capacity_and_hasher(2048, Default::default()); + let message_ids = HashMap::with_capacity_and_hasher(2048, Default::default()); /* Scrap caching for now. When a cached threads file is loaded, we must remove/rehash the * thread nodes that shouldn't exist anymore (e.g. because their file moved from /new to * /cur, or it was deleted). */ - let threads = FnvHashMap::with_capacity_and_hasher(16, Default::default()); - let mailboxes = FnvHashMap::with_capacity_and_hasher(16, Default::default()); + let threads = HashMap::with_capacity_and_hasher(16, Default::default()); + let mailboxes = HashMap::with_capacity_and_hasher(16, Default::default()); Collection { envelopes: Arc::new(RwLock::new(envelopes)), @@ -190,7 +190,7 @@ impl Collection { /// Returns a list of already existing mailboxs whose threads were updated pub fn merge( &mut self, - mut new_envelopes: FnvHashMap, + mut new_envelopes: HashMap, mailbox_hash: MailboxHash, sent_mailbox: Option, ) -> Option> { @@ -407,14 +407,14 @@ impl Collection { } impl Index<&MailboxHash> for Collection { - type Output = FnvHashSet; - fn index(&self, index: &MailboxHash) -> &FnvHashSet { + type Output = HashSet; + fn index(&self, index: &MailboxHash) -> &HashSet { &self.mailboxes[index] } } impl IndexMut<&MailboxHash> for Collection { - fn index_mut(&mut self, index: &MailboxHash) -> &mut FnvHashSet { + fn index_mut(&mut self, index: &MailboxHash) -> &mut HashSet { self.mailboxes.get_mut(index).unwrap() } } diff --git a/melib/src/email.rs b/melib/src/email.rs index dc309db22..b3d5e3f13 100644 --- a/melib/src/email.rs +++ b/melib/src/email.rs @@ -22,7 +22,7 @@ /*! * Email parsing, handling, sending etc. */ -use fnv::FnvHashMap; +use std::collections::HashMap; mod compose; pub use self::compose::*; @@ -138,7 +138,7 @@ pub struct Envelope { message_id: MessageID, in_reply_to: Option, pub references: Option, - other_headers: FnvHashMap, + other_headers: HashMap, timestamp: UnixTimestamp, thread: ThreadNodeHash, @@ -577,11 +577,11 @@ impl Envelope { } } - pub fn other_headers(&self) -> &FnvHashMap { + pub fn other_headers(&self) -> &HashMap { &self.other_headers } - pub fn other_headers_mut(&mut self) -> &mut FnvHashMap { + pub fn other_headers_mut(&mut self) -> &mut HashMap { &mut self.other_headers } diff --git a/melib/src/email/compose.rs b/melib/src/email/compose.rs index c18a22612..e386f76d4 100644 --- a/melib/src/email/compose.rs +++ b/melib/src/email/compose.rs @@ -24,6 +24,7 @@ use crate::backends::BackendOp; use crate::email::attachments::AttachmentBuilder; use crate::shellexpand::ShellExpandTrait; use data_encoding::BASE64_MIME; +use std::collections::HashMap; use std::ffi::OsStr; use std::io::Read; use std::path::{Path, PathBuf}; @@ -35,11 +36,10 @@ pub mod random; //use self::mime::*; use super::parser; -use fnv::FnvHashMap; #[derive(Debug, PartialEq, Eq, Clone)] pub struct Draft { - pub headers: FnvHashMap, + pub headers: HashMap, pub header_order: Vec, pub body: String, @@ -48,7 +48,7 @@ pub struct Draft { impl Default for Draft { fn default() -> Self { - let mut headers = FnvHashMap::with_capacity_and_hasher(8, Default::default()); + let mut headers = HashMap::with_capacity_and_hasher(8, Default::default()); let mut header_order = Vec::with_capacity(8); headers.insert("From".into(), "".into()); headers.insert("To".into(), "".into()); @@ -214,11 +214,11 @@ impl Draft { ret } - pub fn headers_mut(&mut self) -> &mut FnvHashMap { + pub fn headers_mut(&mut self) -> &mut HashMap { &mut self.headers } - pub fn headers(&self) -> &FnvHashMap { + pub fn headers(&self) -> &HashMap { &self.headers } diff --git a/melib/src/lib.rs b/melib/src/lib.rs index 1d3d90760..bf679a9aa 100644 --- a/melib/src/lib.rs +++ b/melib/src/lib.rs @@ -135,7 +135,6 @@ extern crate encoding; #[macro_use] extern crate bitflags; -extern crate fnv; extern crate uuid; pub use smallvec; diff --git a/melib/src/thread.rs b/melib/src/thread.rs index 63fdd4e7e..49ff5c16b 100644 --- a/melib/src/thread.rs +++ b/melib/src/thread.rs @@ -43,9 +43,9 @@ pub use iterators::*; use crate::text_processing::grapheme_clusters::*; use uuid::Uuid; -use fnv::{FnvHashMap, FnvHashSet}; use std::cell::RefCell; use std::cmp::Ordering; +use std::collections::{HashMap, HashSet}; use std::fmt; use std::iter::FromIterator; use std::ops::Index; @@ -56,7 +56,7 @@ use std::sync::{Arc, RwLock}; use smallvec::SmallVec; -type Envelopes = Arc>>; +type Envelopes = Arc>>; macro_rules! uuid_hash_type { ($n:ident) => { @@ -407,15 +407,15 @@ impl ThreadNode { #[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct Threads { - pub thread_nodes: FnvHashMap, + pub thread_nodes: HashMap, root_set: RefCell>, tree_index: RefCell>, - pub groups: FnvHashMap, + pub groups: HashMap, - message_ids: FnvHashMap, ThreadNodeHash>, - pub message_ids_set: FnvHashSet>, - pub missing_message_ids: FnvHashSet>, - pub hash_set: FnvHashSet, + message_ids: HashMap, ThreadNodeHash>, + pub message_ids_set: HashSet>, + pub missing_message_ids: HashSet>, + pub hash_set: HashSet, sort: RefCell<(SortField, SortOrder)>, subsort: RefCell<(SortField, SortOrder)>, } @@ -468,22 +468,19 @@ impl Threads { /* To reconstruct thread information from the mails we need: */ /* a vector to hold thread members */ - let thread_nodes: FnvHashMap = - FnvHashMap::with_capacity_and_hasher( - (length as f64 * 1.2) as usize, - Default::default(), - ); + let thread_nodes: HashMap = + HashMap::with_capacity_and_hasher((length as f64 * 1.2) as usize, Default::default()); /* A hash table of Message IDs */ - let message_ids: FnvHashMap, ThreadNodeHash> = - FnvHashMap::with_capacity_and_hasher(length, Default::default()); + let message_ids: HashMap, ThreadNodeHash> = + HashMap::with_capacity_and_hasher(length, Default::default()); /* A hash set of Message IDs we haven't encountered yet as an Envelope */ - let missing_message_ids: FnvHashSet> = - FnvHashSet::with_capacity_and_hasher(length, Default::default()); + let missing_message_ids: HashSet> = + HashSet::with_capacity_and_hasher(length, Default::default()); /* A hash set of Message IDs we have encountered as a MessageID */ - let message_ids_set: FnvHashSet> = - FnvHashSet::with_capacity_and_hasher(length, Default::default()); - let hash_set: FnvHashSet = - FnvHashSet::with_capacity_and_hasher(length, Default::default()); + let message_ids_set: HashSet> = + HashSet::with_capacity_and_hasher(length, Default::default()); + let hash_set: HashSet = + HashSet::with_capacity_and_hasher(length, Default::default()); Threads { thread_nodes, @@ -582,7 +579,7 @@ impl Threads { pub fn amend(&mut self, envelopes: &mut Envelopes) { let envelopes_lck = envelopes.read().unwrap(); - let new_hash_set = FnvHashSet::from_iter(envelopes_lck.keys().cloned()); + let new_hash_set = HashSet::from_iter(envelopes_lck.keys().cloned()); let difference: Vec = self.hash_set.difference(&new_hash_set).cloned().collect(); @@ -831,7 +828,7 @@ impl Threads { .message_ids .iter() .map(|(a, &b)| (b, a.to_vec())) - .collect::>>(), + .collect::>>(), &envelopes, ); */ @@ -1168,7 +1165,7 @@ impl Threads { thread.message().unwrap() } - pub fn thread_nodes(&self) -> &FnvHashMap { + pub fn thread_nodes(&self) -> &HashMap { &self.thread_nodes } @@ -1206,13 +1203,13 @@ impl Index<&ThreadNodeHash> for Threads { /* fn print_threadnodes( node_hash: ThreadNodeHash, - nodes: &FnvHashMap, + nodes: &HashMap, envelopes: &Envelopes, ) { fn help( level: usize, node_hash: ThreadNodeHash, - nodes: &FnvHashMap, + nodes: &HashMap, envelopes: &Envelopes, ) { eprint!("{}ThreadNode {}\n{}\tmessage: {}\n{}\tparent: {}\n{}\tthread_group: {}\n{}\tchildren (len: {}):\n", @@ -1261,8 +1258,8 @@ struct Graph { /* fn save_graph( node_arr: &[ThreadNodeHash], - nodes: &FnvHashMap, - ids: &FnvHashMap>, + nodes: &HashMap, + ids: &HashMap>, envelopes: &Envelopes, ) { let envelopes = envelopes.read().unwrap(); diff --git a/melib/src/thread/iterators.rs b/melib/src/thread/iterators.rs index 835dad6a3..f52f20934 100644 --- a/melib/src/thread/iterators.rs +++ b/melib/src/thread/iterators.rs @@ -20,8 +20,8 @@ */ use super::{ThreadNode, ThreadNodeHash}; -use fnv::FnvHashMap; use smallvec::SmallVec; +use std::collections::HashMap; /* `ThreadsIterator` returns messages according to the sorted order. For example, for the following * threads: @@ -42,7 +42,7 @@ pub struct ThreadsGroupIterator<'a> { pub(super) root_tree: SmallVec<[ThreadNodeHash; 1024]>, pub(super) pos: usize, pub(super) stack: SmallVec<[usize; 16]>, - pub(super) thread_nodes: &'a FnvHashMap, + pub(super) thread_nodes: &'a HashMap, } impl<'a> Iterator for ThreadsGroupIterator<'a> { type Item = (usize, ThreadNodeHash, bool); @@ -100,7 +100,7 @@ pub struct ThreadGroupIterator<'a> { pub(super) group: ThreadNodeHash, pub(super) pos: usize, pub(super) stack: SmallVec<[usize; 16]>, - pub(super) thread_nodes: &'a FnvHashMap, + pub(super) thread_nodes: &'a HashMap, } impl<'a> Iterator for ThreadGroupIterator<'a> { diff --git a/src/bin.rs b/src/bin.rs index 1d4ff1fcf..0f3fccb93 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -37,7 +37,6 @@ extern crate serde_derive; extern crate linkify; extern crate uuid; -extern crate fnv; extern crate termion; #[macro_use] diff --git a/src/components.rs b/src/components.rs index 0e5b005e9..e0ad87a79 100644 --- a/src/components.rs +++ b/src/components.rs @@ -43,15 +43,15 @@ pub use crate::contacts::*; use std::fmt; use std::fmt::{Debug, Display}; -use fnv::FnvHashMap; +use std::collections::HashMap; use uuid::Uuid; use super::{Key, StatusEvent, UIEvent}; pub type ComponentId = Uuid; -pub type ShortcutMap = FnvHashMap<&'static str, Key>; -pub type ShortcutMaps = FnvHashMap<&'static str, ShortcutMap>; +pub type ShortcutMap = HashMap<&'static str, Key>; +pub type ShortcutMaps = HashMap<&'static str, ShortcutMap>; /// Types implementing this Trait can draw on the terminal and receive events. /// If a type wants to skip drawing if it has not changed anything, it can hold some flag in its diff --git a/src/components/contacts.rs b/src/components/contacts.rs index cb2b91076..c01c89a64 100644 --- a/src/components/contacts.rs +++ b/src/components/contacts.rs @@ -20,7 +20,7 @@ */ use super::*; -use fnv::FnvHashMap; +use std::collections::HashMap; mod contact_list; @@ -205,7 +205,7 @@ impl Component for ContactManager { let fields = std::mem::replace(&mut self.form, FormWidget::default()) .collect() .unwrap(); - let fields: FnvHashMap = fields + let fields: HashMap = fields .into_iter() .map(|(s, v)| { ( diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs index 1758bf70d..b832c6320 100644 --- a/src/components/mail/listing.rs +++ b/src/components/mail/listing.rs @@ -22,6 +22,7 @@ use super::*; use crate::types::segment_tree::SegmentTree; use smallvec::SmallVec; +use std::collections::{HashMap, HashSet}; use std::ops::{Deref, DerefMut}; mod conversations; @@ -1149,7 +1150,7 @@ impl Listing { debug!("BUG: invalid area in print_account"); } // Each entry and its index in the account - let mailboxes: FnvHashMap = context.accounts[a.index] + let mailboxes: HashMap = context.accounts[a.index] .mailbox_entries .iter() .map(|(&hash, entry)| (hash, entry.ref_mailbox.clone())) diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index f0629ce07..d12bc0041 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -54,15 +54,15 @@ pub struct CompactListing { length: usize, sort: (SortField, SortOrder), subsort: (SortField, SortOrder), - all_threads: fnv::FnvHashSet, - order: FnvHashMap, + all_threads: HashSet, + order: HashMap, /// Cache current view. data_columns: DataColumns, filter_term: String, filtered_selection: Vec, - filtered_order: FnvHashMap, - selection: FnvHashMap, + filtered_order: HashMap, + selection: HashMap, /// If we must redraw on next redraw event dirty: bool, force_draw: bool, @@ -661,12 +661,12 @@ impl CompactListing { length: 0, sort: (Default::default(), Default::default()), subsort: (SortField::Date, SortOrder::Desc), - all_threads: fnv::FnvHashSet::default(), - order: FnvHashMap::default(), + all_threads: HashSet::default(), + order: HashMap::default(), filter_term: String::new(), filtered_selection: Vec::new(), - filtered_order: FnvHashMap::default(), - selection: FnvHashMap::default(), + filtered_order: HashMap::default(), + selection: HashMap::default(), row_updates: SmallVec::new(), data_columns: DataColumns::default(), dirty: true, diff --git a/src/components/mail/listing/conversations.rs b/src/components/mail/listing/conversations.rs index 93ec2f1ea..30c77faed 100644 --- a/src/components/mail/listing/conversations.rs +++ b/src/components/mail/listing/conversations.rs @@ -33,15 +33,15 @@ pub struct ConversationsListing { length: usize, sort: (SortField, SortOrder), subsort: (SortField, SortOrder), - all_threads: fnv::FnvHashSet, - order: FnvHashMap, + all_threads: HashSet, + order: HashMap, /// Cache current view. content: CellBuffer, filter_term: String, filtered_selection: Vec, - filtered_order: FnvHashMap, - selection: FnvHashMap, + filtered_order: HashMap, + selection: HashMap, /// If we must redraw on next redraw event dirty: bool, force_draw: bool, @@ -568,12 +568,12 @@ impl ConversationsListing { length: 0, sort: (Default::default(), Default::default()), subsort: (SortField::Date, SortOrder::Desc), - order: FnvHashMap::default(), - all_threads: fnv::FnvHashSet::default(), + order: HashMap::default(), + all_threads: HashSet::default(), filter_term: String::new(), filtered_selection: Vec::new(), - filtered_order: FnvHashMap::default(), - selection: FnvHashMap::default(), + filtered_order: HashMap::default(), + selection: HashMap::default(), row_updates: SmallVec::new(), content: Default::default(), dirty: true, diff --git a/src/components/mail/listing/plain.rs b/src/components/mail/listing/plain.rs index d42efb286..3cc7e3d77 100644 --- a/src/components/mail/listing/plain.rs +++ b/src/components/mail/listing/plain.rs @@ -53,16 +53,16 @@ pub struct PlainListing { length: usize, sort: (SortField, SortOrder), subsort: (SortField, SortOrder), - all_envelopes: fnv::FnvHashSet, - order: FnvHashMap, + all_envelopes: HashSet, + order: HashMap, /// Cache current view. data_columns: DataColumns, filter_term: String, filtered_selection: Vec, - filtered_order: FnvHashMap, - selection: FnvHashMap, - thread_node_hashes: FnvHashMap, + filtered_order: HashMap, + selection: HashMap, + thread_node_hashes: HashMap, local_collection: Vec, /// If we must redraw on next redraw event dirty: bool, @@ -627,14 +627,14 @@ impl PlainListing { length: 0, sort: (Default::default(), Default::default()), subsort: (SortField::Date, SortOrder::Desc), - all_envelopes: fnv::FnvHashSet::default(), + all_envelopes: HashSet::default(), local_collection: Vec::new(), - thread_node_hashes: FnvHashMap::default(), - order: FnvHashMap::default(), + thread_node_hashes: HashMap::default(), + order: HashMap::default(), filter_term: String::new(), filtered_selection: Vec::new(), - filtered_order: FnvHashMap::default(), - selection: FnvHashMap::default(), + filtered_order: HashMap::default(), + selection: HashMap::default(), row_updates: SmallVec::new(), _row_updates: SmallVec::new(), data_columns: DataColumns::default(), diff --git a/src/components/mail/listing/thread.rs b/src/components/mail/listing/thread.rs index 53cb486a2..d21dedaf1 100644 --- a/src/components/mail/listing/thread.rs +++ b/src/components/mail/listing/thread.rs @@ -39,7 +39,7 @@ pub struct ThreadListing { color_cache: ColorCache, row_updates: SmallVec<[ThreadHash; 8]>, - order: FnvHashMap, + order: HashMap, /// If we must redraw on next redraw event dirty: bool, /// If `self.view` is focused or not. @@ -153,7 +153,7 @@ impl MailListingTrait for ThreadListing { .filter_map(|r| threads.groups[&r].root().map(|r| r.root)) .collect::<_>(); let mut iter = threads.threads_group_iter(roots).peekable(); - let thread_nodes: &FnvHashMap = &threads.thread_nodes(); + let thread_nodes: &HashMap = &threads.thread_nodes(); /* This is just a desugared for loop so that we can use .peek() */ let mut idx = 0; while let Some((indentation, thread_node_hash, has_sibling)) = iter.next() { @@ -406,7 +406,7 @@ impl ThreadListing { content: CellBuffer::new(0, 0, Cell::with_char(' ')), color_cache: ColorCache::default(), row_updates: SmallVec::new(), - order: FnvHashMap::default(), + order: HashMap::default(), dirty: true, unfocused: false, view: None, diff --git a/src/components/utilities.rs b/src/components/utilities.rs index 9afab637e..7e81145da 100644 --- a/src/components/utilities.rs +++ b/src/components/utilities.rs @@ -27,7 +27,7 @@ use text_processing::Reflow; mod widgets; pub use self::widgets::*; -use fnv::FnvHashSet; +use std::collections::HashSet; /// A horizontally split in half container. #[derive(Debug)] @@ -814,8 +814,7 @@ impl Component for Pager { self.dirty = value; } fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { - let config_map: FnvHashMap<&'static str, Key> = - context.settings.shortcuts.pager.key_values(); + let config_map: HashMap<&'static str, Key> = context.settings.shortcuts.pager.key_values(); let mut ret: ShortcutMaps = Default::default(); ret.insert(Pager::DESCRIPTION, config_map); ret @@ -986,7 +985,7 @@ impl Component for StatusBar { return; } - let mut unique_suggestions: FnvHashSet<&str> = FnvHashSet::default(); + let mut unique_suggestions: HashSet<&str> = HashSet::default(); let mut suggestions: Vec = self .cmd_history .iter() diff --git a/src/components/utilities/widgets.rs b/src/components/utilities/widgets.rs index 21e0b24fb..632c60e2e 100644 --- a/src/components/utilities/widgets.rs +++ b/src/components/utilities/widgets.rs @@ -20,7 +20,7 @@ */ use super::*; -use fnv::FnvHashMap; +use std::collections::HashMap; type AutoCompleteFn = Box Vec + Send + Sync>; @@ -298,7 +298,7 @@ impl fmt::Display for Field { #[derive(Debug, Default)] pub struct FormWidget { - fields: FnvHashMap, + fields: HashMap, layout: Vec, buttons: ButtonWidget, @@ -375,11 +375,11 @@ impl FormWidget { self.fields.insert(value.0, value.1); } - pub fn values_mut(&mut self) -> &mut FnvHashMap { + pub fn values_mut(&mut self) -> &mut HashMap { &mut self.fields } - pub fn collect(self) -> Option> { + pub fn collect(self) -> Option> { if let Some(true) = self.buttons_result() { Some(self.fields) } else { @@ -598,7 +598,7 @@ pub struct ButtonWidget where T: 'static + std::fmt::Debug + Default + Send + Sync, { - buttons: FnvHashMap, + buttons: HashMap, layout: Vec, result: Option, diff --git a/src/conf/accounts.rs b/src/conf/accounts.rs index 305ea1e3f..d25189d41 100644 --- a/src/conf/accounts.rs +++ b/src/conf/accounts.rs @@ -24,7 +24,6 @@ */ use super::{AccountConf, FileMailboxConf}; -use fnv::FnvHashMap; use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext}; use melib::backends::{ BackendOp, Backends, MailBackend, Mailbox, MailboxHash, NotifyFn, ReadOnlyOp, RefreshEvent, @@ -37,6 +36,7 @@ use melib::thread::{SortField, SortOrder, ThreadNode, ThreadNodeHash, Threads}; use melib::AddressBook; use melib::Collection; use smallvec::SmallVec; +use std::collections::HashMap; use crate::types::UIEvent::{self, EnvelopeRemove, EnvelopeRename, EnvelopeUpdate, Notification}; use crate::{StatusEvent, ThreadEvent}; @@ -114,7 +114,7 @@ pub struct Account { pub index: usize, name: String, pub is_online: bool, - pub(crate) mailbox_entries: FnvHashMap, + pub(crate) mailbox_entries: HashMap, pub(crate) mailboxes_order: Vec, tree: Vec, sent_mailbox: Option, @@ -251,7 +251,7 @@ impl Account { } fn init(&mut self) { - let mut ref_mailboxes: FnvHashMap = + let mut ref_mailboxes: HashMap = match self.backend.read().unwrap().mailboxes() { Ok(f) => f, Err(err) => { @@ -259,8 +259,8 @@ impl Account { return; } }; - let mut mailbox_entries: FnvHashMap = - FnvHashMap::with_capacity_and_hasher(ref_mailboxes.len(), Default::default()); + let mut mailbox_entries: HashMap = + HashMap::with_capacity_and_hasher(ref_mailboxes.len(), Default::default()); let mut mailboxes_order: Vec = Vec::with_capacity(ref_mailboxes.len()); let mut sent_mailbox = None; @@ -775,7 +775,7 @@ impl Account { .unwrap() .into_iter() .map(|e| (e.hash(), e)) - .collect::>(); + .collect::>(); if let Some(updated_mailboxes) = self.collection .merge(envelopes, mailbox_hash, self.sent_mailbox) @@ -1206,7 +1206,7 @@ impl IndexMut<&MailboxHash> for Account { fn build_mailboxes_order( tree: &mut Vec, - mailbox_entries: &FnvHashMap, + mailbox_entries: &HashMap, mailboxes_order: &mut Vec, ) { tree.clear(); @@ -1215,7 +1215,7 @@ fn build_mailboxes_order( if f.ref_mailbox.parent().is_none() { fn rec( h: MailboxHash, - mailbox_entries: &FnvHashMap, + mailbox_entries: &HashMap, depth: usize, ) -> MailboxNode { let mut node = MailboxNode { diff --git a/src/conf/shortcuts.rs b/src/conf/shortcuts.rs index dec44c392..320b30832 100644 --- a/src/conf/shortcuts.rs +++ b/src/conf/shortcuts.rs @@ -21,7 +21,7 @@ use crate::override_def; use crate::terminal::Key; -use fnv::FnvHashMap; +use std::collections::HashMap; #[macro_export] macro_rules! shortcut { @@ -95,7 +95,7 @@ macro_rules! shortcut_key_values { } } /// Returns a hashmap of all shortcuts and their values - pub fn key_values(&self) -> FnvHashMap<&'static str, Key> { + pub fn key_values(&self) -> HashMap<&'static str, Key> { [ $((stringify!($fname),(self.$fname).clone()),)* ].iter().cloned().collect() diff --git a/src/mailcap.rs b/src/mailcap.rs index b88c660c4..5bcd92d24 100644 --- a/src/mailcap.rs +++ b/src/mailcap.rs @@ -24,10 +24,10 @@ use crate::split_command; use crate::state::Context; use crate::types::{create_temp_file, ForkType, UIEvent}; -use fnv::FnvHashMap; use melib::attachments::decode; use melib::text_processing::GlobMatch; use melib::{email::Attachment, MeliError, Result}; +use std::collections::HashMap; use std::io::Read; use std::io::Write; use std::path::PathBuf; @@ -72,7 +72,7 @@ impl MailcapEntry { } } - let mut hash_map = FnvHashMap::default(); + let mut hash_map = HashMap::new(); let mut content = String::new(); std::fs::File::open(mailcap_path.as_path())?.read_to_string(&mut content)?; diff --git a/src/managesieve.rs b/src/managesieve.rs index 738221e82..84e6a91fe 100644 --- a/src/managesieve.rs +++ b/src/managesieve.rs @@ -31,7 +31,6 @@ extern crate serde_derive; extern crate linkify; extern crate uuid; -extern crate fnv; extern crate termion; #[macro_use] diff --git a/src/plugins/backend.rs b/src/plugins/backend.rs index 854d39b4d..07982dbd1 100644 --- a/src/plugins/backend.rs +++ b/src/plugins/backend.rs @@ -20,7 +20,6 @@ */ use super::*; -use fnv::FnvHashMap; use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext}; use melib::backends::MailboxHash; use melib::backends::{Backend, BackendOp, Backends, MailBackend, Mailbox, RefreshEventConsumer}; @@ -28,6 +27,7 @@ use melib::conf::AccountSettings; use melib::email::{Envelope, EnvelopeHash, Flag}; use melib::error::{MeliError, Result}; use std::collections::BTreeMap; +use std::collections::HashMap; use std::sync::{Arc, Mutex, RwLock}; // TODO replace with melib::Envelope after simplifying melib::Envelope's @@ -193,8 +193,8 @@ impl MailBackend for PluginBackend { Err(MeliError::new("Unimplemented.")) } - fn mailboxes(&self) -> Result> { - let mut ret: FnvHashMap = Default::default(); + fn mailboxes(&self) -> Result> { + let mut ret: HashMap = Default::default(); ret.insert(0, Mailbox::default()); Ok(ret) } @@ -214,7 +214,7 @@ impl MailBackend for PluginBackend { fn create_mailbox( &mut self, _name: String, - ) -> Result<(MailboxHash, FnvHashMap)> { + ) -> Result<(MailboxHash, HashMap)> { Err(MeliError::new("Unimplemented.")) } fn tags(&self) -> Option>>> { diff --git a/src/state.rs b/src/state.rs index a7e35fac5..ff434454a 100644 --- a/src/state.rs +++ b/src/state.rs @@ -33,8 +33,8 @@ use crate::plugins::PluginManager; use melib::backends::{MailboxHash, NotifyFn}; use crossbeam::channel::{unbounded, Receiver, Sender}; -use fnv::FnvHashMap; use smallvec::SmallVec; +use std::collections::HashMap; use std::env; use std::io::Write; use std::thread; @@ -89,7 +89,7 @@ impl InputHandler { /// A context container for loaded settings, accounts, UI changes, etc. pub struct Context { pub accounts: Vec, - pub mailbox_hashes: FnvHashMap, + pub mailbox_hashes: HashMap, pub settings: Settings, pub runtime_settings: Settings, @@ -315,7 +315,7 @@ impl State { context: Context { accounts, - mailbox_hashes: FnvHashMap::with_capacity_and_hasher(1, Default::default()), + mailbox_hashes: HashMap::with_capacity_and_hasher(1, Default::default()), settings: settings.clone(), runtime_settings: settings, diff --git a/src/workers.rs b/src/workers.rs index b6c0c64eb..71ed329f1 100644 --- a/src/workers.rs +++ b/src/workers.rs @@ -26,10 +26,10 @@ use crossbeam::{ channel::{bounded, unbounded, Sender}, select, }; -use fnv::FnvHashMap; use melib::async_workers::{Work, WorkContext}; use melib::datetime::{self, UnixTimestamp}; use melib::text_processing::Truncate; +use std::collections::HashMap; use std::sync::Arc; use std::sync::Mutex; use std::thread; @@ -59,9 +59,9 @@ pub struct WorkController { pub queue: WorkQueue, thread_end_tx: Sender, /// Worker threads that take up on jobs from self.queue - pub threads: Arc>>, + pub threads: Arc>>, /// Special function threads that live indefinitely (eg watching a mailbox) - pub static_threads: Arc>>, + pub static_threads: Arc>>, work_context: WorkContext, } @@ -177,11 +177,11 @@ impl WorkController { // Create a SyncFlag to share whether or not there are more jobs to be done. let (thread_end_tx, thread_end_rx) = bounded(1); - let threads_lock: Arc>> = - Arc::new(Mutex::new(FnvHashMap::default())); + let threads_lock: Arc>> = + Arc::new(Mutex::new(HashMap::default())); - let static_threads_lock: Arc>> = - Arc::new(Mutex::new(FnvHashMap::default())); + let static_threads_lock: Arc>> = + Arc::new(Mutex::new(HashMap::default())); let mut threads = threads_lock.lock().unwrap(); /* spawn worker threads */