Remove fnv crate

async
Manos Pitsidianakis 2020-05-10 21:14:49 +03:00
parent b5b9982d9e
commit eb701695f7
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
38 changed files with 203 additions and 217 deletions

2
Cargo.lock generated
View File

@ -685,7 +685,6 @@ dependencies = [
"bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "linkify 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"melib 0.5.0", "melib 0.5.0",
@ -720,7 +719,6 @@ dependencies = [
"crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -34,7 +34,6 @@ serde = "1.0.71"
serde_derive = "1.0.71" serde_derive = "1.0.71"
serde_json = "1.0" serde_json = "1.0"
toml = "0.5.3" toml = "0.5.3"
fnv = "1.0.3" # >:c
linkify = "0.3.1" # >:c linkify = "0.3.1" # >:c
xdg-utils = "0.3.0" xdg-utils = "0.3.0"
nom = "3.2.0" nom = "3.2.0"

View File

@ -22,7 +22,6 @@ bitflags = "1.0"
crossbeam = "0.7.2" crossbeam = "0.7.2"
data-encoding = "2.1.1" data-encoding = "2.1.1"
encoding = "0.2.33" encoding = "0.2.33"
fnv = "1.0.3"
memmap = { version = "0.5.2", optional = true } memmap = { version = "0.5.2", optional = true }
nom = "3.2.0" nom = "3.2.0"
notify = { version = "4.0.1", optional = true } notify = { version = "4.0.1", optional = true }

View File

@ -23,7 +23,7 @@
pub mod vcard; pub mod vcard;
use crate::datetime::{self, UnixTimestamp}; use crate::datetime::{self, UnixTimestamp};
use fnv::FnvHashMap; use std::collections::HashMap;
use uuid::Uuid; use uuid::Uuid;
use std::ops::Deref; use std::ops::Deref;
@ -61,7 +61,7 @@ pub struct AddressBook {
display_name: String, display_name: String,
created: UnixTimestamp, created: UnixTimestamp,
last_edited: UnixTimestamp, last_edited: UnixTimestamp,
pub cards: FnvHashMap<CardId, Card>, pub cards: HashMap<CardId, Card>,
} }
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
@ -80,7 +80,7 @@ pub struct Card {
color: u8, color: u8,
last_edited: UnixTimestamp, last_edited: UnixTimestamp,
extra_properties: FnvHashMap<String, String>, extra_properties: HashMap<String, String>,
/// If true, we can't make any changes because we do not manage this resource. /// If true, we can't make any changes because we do not manage this resource.
external_resource: bool, external_resource: bool,
@ -92,7 +92,7 @@ impl AddressBook {
display_name, display_name,
created: datetime::now(), created: datetime::now(),
last_edited: datetime::now(), last_edited: datetime::now(),
cards: FnvHashMap::default(), cards: HashMap::default(),
} }
} }
@ -132,9 +132,9 @@ impl AddressBook {
} }
impl Deref for AddressBook { impl Deref for AddressBook {
type Target = FnvHashMap<CardId, Card>; type Target = HashMap<CardId, Card>;
fn deref(&self) -> &FnvHashMap<CardId, Card> { fn deref(&self) -> &HashMap<CardId, Card> {
&self.cards &self.cards
} }
} }
@ -156,7 +156,7 @@ impl Card {
last_edited: datetime::now(), last_edited: datetime::now(),
external_resource: false, external_resource: false,
extra_properties: FnvHashMap::default(), extra_properties: HashMap::default(),
color: 0, color: 0,
} }
} }
@ -229,7 +229,7 @@ impl Card {
self.extra_properties.get(key).map(String::as_str) self.extra_properties.get(key).map(String::as_str)
} }
pub fn extra_properties(&self) -> &FnvHashMap<String, String> { pub fn extra_properties(&self) -> &HashMap<String, String> {
&self.extra_properties &self.extra_properties
} }
@ -242,8 +242,8 @@ impl Card {
} }
} }
impl From<FnvHashMap<String, String>> for Card { impl From<HashMap<String, String>> for Card {
fn from(mut map: FnvHashMap<String, String>) -> Card { fn from(mut map: HashMap<String, String>) -> Card {
let mut card = Card::new(); let mut card = Card::new();
if let Some(val) = map.remove("TITLE") { if let Some(val) = map.remove("TITLE") {
card.title = val; card.title = val;

View File

@ -23,7 +23,7 @@
use super::*; use super::*;
use crate::error::{MeliError, Result}; use crate::error::{MeliError, Result};
use crate::parsec::{match_literal_anycase, one_or_more, peek, prefix, take_until, Parser}; 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; use std::convert::TryInto;
/* Supported vcard versions */ /* Supported vcard versions */
@ -50,14 +50,14 @@ static FOOTER: &'static str = "END:VCARD\r\n";
#[derive(Debug)] #[derive(Debug)]
pub struct VCard<T: VCardVersion>( pub struct VCard<T: VCardVersion>(
fnv::FnvHashMap<String, ContentLine>, HashMap<String, ContentLine>,
std::marker::PhantomData<*const T>, std::marker::PhantomData<*const T>,
); );
impl<V: VCardVersion> VCard<V> { impl<V: VCardVersion> VCard<V> {
pub fn new_v4() -> VCard<impl VCardVersion> { pub fn new_v4() -> VCard<impl VCardVersion> {
VCard( VCard(
FnvHashMap::default(), HashMap::default(),
std::marker::PhantomData::<*const VCardVersion4>, std::marker::PhantomData::<*const VCardVersion4>,
) )
} }
@ -78,7 +78,7 @@ impl CardDeserializer {
&input[HEADER.len()..input.len() - FOOTER.len()] &input[HEADER.len()..input.len() - FOOTER.len()]
}; };
let mut ret = FnvHashMap::default(); let mut ret = HashMap::default();
enum Stage { enum Stage {
Group, Group,

View File

@ -64,8 +64,8 @@ use std::fmt::Debug;
use std::ops::Deref; use std::ops::Deref;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use fnv::FnvHashMap;
use std; use std;
use std::collections::HashMap;
#[macro_export] #[macro_export]
macro_rules! get_path_hash { macro_rules! get_path_hash {
@ -88,7 +88,7 @@ pub type BackendCreator = Box<
/// A hashmap containing all available mail backends. /// A hashmap containing all available mail backends.
/// An abstraction over any available backends. /// An abstraction over any available backends.
pub struct Backends { pub struct Backends {
map: FnvHashMap<std::string::String, Backend>, map: HashMap<std::string::String, Backend>,
} }
pub struct Backend { pub struct Backend {
@ -111,7 +111,7 @@ pub const NOTMUCH_ERROR_MSG: &'static str = "this version of meli is not compile
impl Backends { impl Backends {
pub fn new() -> Self { pub fn new() -> Self {
let mut b = Backends { 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")] #[cfg(feature = "maildir_backend")]
{ {
@ -284,7 +284,7 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
sender: RefreshEventConsumer, sender: RefreshEventConsumer,
work_context: WorkContext, work_context: WorkContext,
) -> Result<std::thread::ThreadId>; ) -> Result<std::thread::ThreadId>;
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>>; fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>>;
fn operation(&self, hash: EnvelopeHash) -> Box<dyn BackendOp>; fn operation(&self, hash: EnvelopeHash) -> Box<dyn BackendOp>;
fn save(&self, bytes: &[u8], mailbox: &str, flags: Option<Flag>) -> Result<()>; fn save(&self, bytes: &[u8], mailbox: &str, flags: Option<Flag>) -> Result<()>;
@ -303,14 +303,14 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
fn create_mailbox( fn create_mailbox(
&mut self, &mut self,
_path: String, _path: String,
) -> Result<(MailboxHash, FnvHashMap<MailboxHash, Mailbox>)> { ) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
Err(MeliError::new("Unimplemented.")) Err(MeliError::new("Unimplemented."))
} }
fn delete_mailbox( fn delete_mailbox(
&mut self, &mut self,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> Result<FnvHashMap<MailboxHash, Mailbox>> { ) -> Result<HashMap<MailboxHash, Mailbox>> {
Err(MeliError::new("Unimplemented.")) Err(MeliError::new("Unimplemented."))
} }

View File

@ -43,8 +43,8 @@ use crate::backends::{BackendMailbox, MailBackend, Mailbox, RefreshEventConsumer
use crate::conf::AccountSettings; use crate::conf::AccountSettings;
use crate::email::*; use crate::email::*;
use crate::error::{MeliError, Result}; use crate::error::{MeliError, Result};
use fnv::{FnvHashMap, FnvHashSet};
use std::collections::{hash_map::DefaultHasher, BTreeMap}; use std::collections::{hash_map::DefaultHasher, BTreeMap};
use std::collections::{HashMap, HashSet};
use std::hash::Hasher; use std::hash::Hasher;
use std::str::FromStr; use std::str::FromStr;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
@ -87,7 +87,7 @@ impl std::ops::Deref for IsSubscribedFn {
&self.0 &self.0
} }
} }
type Capabilities = FnvHashSet<Vec<u8>>; type Capabilities = HashSet<Vec<u8>>;
#[macro_export] #[macro_export]
macro_rules! get_conf_val { macro_rules! get_conf_val {
@ -120,11 +120,11 @@ macro_rules! get_conf_val {
#[derive(Debug)] #[derive(Debug)]
pub struct UIDStore { pub struct UIDStore {
uidvalidity: Arc<Mutex<FnvHashMap<MailboxHash, UID>>>, uidvalidity: Arc<Mutex<HashMap<MailboxHash, UID>>>,
hash_index: Arc<Mutex<FnvHashMap<EnvelopeHash, (UID, MailboxHash)>>>, hash_index: Arc<Mutex<HashMap<EnvelopeHash, (UID, MailboxHash)>>>,
uid_index: Arc<Mutex<FnvHashMap<UID, EnvelopeHash>>>, uid_index: Arc<Mutex<HashMap<UID, EnvelopeHash>>>,
byte_cache: Arc<Mutex<FnvHashMap<UID, EnvelopeCache>>>, byte_cache: Arc<Mutex<HashMap<UID, EnvelopeCache>>>,
} }
#[derive(Debug)] #[derive(Debug)]
pub struct ImapType { pub struct ImapType {
@ -137,7 +137,7 @@ pub struct ImapType {
can_create_flags: Arc<Mutex<bool>>, can_create_flags: Arc<Mutex<bool>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>, tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, ImapMailbox>>>, mailboxes: Arc<RwLock<HashMap<MailboxHash, ImapMailbox>>>,
} }
#[inline(always)] #[inline(always)]
@ -407,7 +407,7 @@ impl MailBackend for ImapType {
Ok(handle.thread().id()) Ok(handle.thread().id())
} }
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> { fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
{ {
let mailboxes = self.mailboxes.read().unwrap(); let mailboxes = self.mailboxes.read().unwrap();
if !mailboxes.is_empty() { if !mailboxes.is_empty() {
@ -420,10 +420,7 @@ impl MailBackend for ImapType {
let mut mailboxes = self.mailboxes.write()?; let mut mailboxes = self.mailboxes.write()?;
*mailboxes = ImapType::imap_mailboxes(&self.connection)?; *mailboxes = ImapType::imap_mailboxes(&self.connection)?;
mailboxes.retain(|_, f| (self.is_subscribed)(f.path())); mailboxes.retain(|_, f| (self.is_subscribed)(f.path()));
let keys = mailboxes let keys = mailboxes.keys().cloned().collect::<HashSet<MailboxHash>>();
.keys()
.cloned()
.collect::<FnvHashSet<MailboxHash>>();
let mut uid_lock = self.uid_store.uidvalidity.lock().unwrap(); let mut uid_lock = self.uid_store.uidvalidity.lock().unwrap();
for f in mailboxes.values_mut() { for f in mailboxes.values_mut() {
uid_lock.entry(f.hash()).or_default(); uid_lock.entry(f.hash()).or_default();
@ -512,7 +509,7 @@ impl MailBackend for ImapType {
fn create_mailbox( fn create_mailbox(
&mut self, &mut self,
mut path: String, mut path: String,
) -> Result<(MailboxHash, FnvHashMap<MailboxHash, Mailbox>)> { ) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
/* Must transform path to something the IMAP server will accept /* Must transform path to something the IMAP server will accept
* *
* Each root mailbox has a hierarchy delimeter reported by the LIST entry. All paths * 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( fn delete_mailbox(
&mut self, &mut self,
mailbox_hash: MailboxHash, mailbox_hash: MailboxHash,
) -> Result<FnvHashMap<MailboxHash, Mailbox>> { ) -> Result<HashMap<MailboxHash, Mailbox>> {
let mut mailboxes = self.mailboxes.write().unwrap(); let mut mailboxes = self.mailboxes.write().unwrap();
let permissions = mailboxes[&mailbox_hash].permissions(); let permissions = mailboxes[&mailbox_hash].permissions();
if !permissions.delete_mailbox { if !permissions.delete_mailbox {
@ -939,8 +936,8 @@ impl ImapType {
pub fn imap_mailboxes( pub fn imap_mailboxes(
connection: &Arc<Mutex<ImapConnection>>, connection: &Arc<Mutex<ImapConnection>>,
) -> Result<FnvHashMap<MailboxHash, ImapMailbox>> { ) -> Result<HashMap<MailboxHash, ImapMailbox>> {
let mut mailboxes: FnvHashMap<MailboxHash, ImapMailbox> = Default::default(); let mut mailboxes: HashMap<MailboxHash, ImapMailbox> = Default::default();
let mut res = String::with_capacity(8 * 1024); let mut res = String::with_capacity(8 * 1024);
let mut conn = try_lock(&connection)?; let mut conn = try_lock(&connection)?;
conn.send_command(b"LIST \"\" \"*\"")?; conn.send_command(b"LIST \"\" \"*\"")?;

View File

@ -25,8 +25,8 @@ use crate::error::*;
use std::io::Read; use std::io::Read;
use std::io::Write; use std::io::Write;
extern crate native_tls; extern crate native_tls;
use fnv::FnvHashSet;
use native_tls::TlsConnector; use native_tls::TlsConnector;
use std::collections::HashSet;
use std::iter::FromIterator; use std::iter::FromIterator;
use std::net::SocketAddr; use std::net::SocketAddr;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@ -241,9 +241,7 @@ impl ImapStream {
capabilities = protocol_parser::capabilities(l.as_bytes()) capabilities = protocol_parser::capabilities(l.as_bytes())
.to_full_result() .to_full_result()
.map(|capabilities| { .map(|capabilities| {
FnvHashSet::from_iter( HashSet::from_iter(capabilities.into_iter().map(|s: &[u8]| s.to_vec()))
capabilities.into_iter().map(|s: &[u8]| s.to_vec()),
)
}) })
.ok(); .ok();
} }
@ -270,7 +268,7 @@ impl ImapStream {
ret.send_command(b"CAPABILITY")?; ret.send_command(b"CAPABILITY")?;
ret.read_response(&mut res).unwrap(); ret.read_response(&mut res).unwrap();
let capabilities = protocol_parser::capabilities(res.as_bytes()).to_full_result()?; 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)) Ok((capabilities, ret))
} else { } else {
let capabilities = capabilities.unwrap(); let capabilities = capabilities.unwrap();

View File

@ -28,7 +28,7 @@ pub struct ImapWatchKit {
pub is_online: Arc<Mutex<(Instant, Result<()>)>>, pub is_online: Arc<Mutex<(Instant, Result<()>)>>,
pub main_conn: Arc<Mutex<ImapConnection>>, pub main_conn: Arc<Mutex<ImapConnection>>,
pub uid_store: Arc<UIDStore>, pub uid_store: Arc<UIDStore>,
pub mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, ImapMailbox>>>, pub mailboxes: Arc<RwLock<HashMap<MailboxHash, ImapMailbox>>>,
pub sender: RefreshEventConsumer, pub sender: RefreshEventConsumer,
pub work_context: WorkContext, pub work_context: WorkContext,
pub tag_index: Arc<RwLock<BTreeMap<u64, String>>>, pub tag_index: Arc<RwLock<BTreeMap<u64, String>>>,

View File

@ -26,9 +26,8 @@ use crate::backends::{BackendMailbox, MailBackend, Mailbox, RefreshEventConsumer
use crate::conf::AccountSettings; use crate::conf::AccountSettings;
use crate::email::*; use crate::email::*;
use crate::error::{MeliError, Result}; use crate::error::{MeliError, Result};
use fnv::FnvHashMap;
use reqwest::blocking::Client; use reqwest::blocking::Client;
use std::collections::BTreeMap; use std::collections::{BTreeMap, HashMap};
use std::str::FromStr; use std::str::FromStr;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use std::time::Instant; use std::time::Instant;
@ -175,9 +174,9 @@ macro_rules! get_conf_val {
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct Store { pub struct Store {
byte_cache: FnvHashMap<EnvelopeHash, EnvelopeCache>, byte_cache: HashMap<EnvelopeHash, EnvelopeCache>,
id_store: FnvHashMap<EnvelopeHash, Id>, id_store: HashMap<EnvelopeHash, Id>,
blob_id_store: FnvHashMap<EnvelopeHash, Id>, blob_id_store: HashMap<EnvelopeHash, Id>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -189,7 +188,7 @@ pub struct JmapType {
connection: Arc<JmapConnection>, connection: Arc<JmapConnection>,
store: Arc<RwLock<Store>>, store: Arc<RwLock<Store>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>, tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, JmapMailbox>>>, mailboxes: Arc<RwLock<HashMap<MailboxHash, JmapMailbox>>>,
} }
impl MailBackend for JmapType { impl MailBackend for JmapType {
@ -239,7 +238,7 @@ impl MailBackend for JmapType {
Err(MeliError::from("JMAP watch for updates is unimplemented")) Err(MeliError::from("JMAP watch for updates is unimplemented"))
} }
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> { fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
if self.mailboxes.read().unwrap().is_empty() { if self.mailboxes.read().unwrap().is_empty() {
let mailboxes = std::dbg!(protocol::get_mailboxes(&self.connection))?; let mailboxes = std::dbg!(protocol::get_mailboxes(&self.connection))?;
*self.mailboxes.write().unwrap() = mailboxes; *self.mailboxes.write().unwrap() = mailboxes;
@ -291,7 +290,7 @@ impl JmapType {
connection: Arc::new(JmapConnection::new(&server_conf, online.clone())?), connection: Arc::new(JmapConnection::new(&server_conf, online.clone())?),
store: Arc::new(RwLock::new(Store::default())), store: Arc::new(RwLock::new(Store::default())),
tag_index: Arc::new(RwLock::new(Default::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(), account_name: s.name.clone(),
online, online,
is_subscribed: Arc::new(IsSubscribedFn(is_subscribed)), is_subscribed: Arc::new(IsSubscribedFn(is_subscribed)),

View File

@ -29,7 +29,7 @@ pub struct JmapConnection {
pub online_status: Arc<Mutex<(Instant, Result<()>)>>, pub online_status: Arc<Mutex<(Instant, Result<()>)>>,
pub server_conf: JmapServerConf, pub server_conf: JmapServerConf,
pub account_id: Arc<Mutex<String>>, pub account_id: Arc<Mutex<String>>,
pub method_call_states: Arc<Mutex<FnvHashMap<&'static str, String>>>, pub method_call_states: Arc<Mutex<HashMap<&'static str, String>>>,
} }
impl JmapConnection { impl JmapConnection {

View File

@ -25,6 +25,7 @@ use serde::Serialize;
use serde_json::{json, Value}; use serde_json::{json, Value};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::hash_map::DefaultHasher; use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
@ -94,7 +95,7 @@ impl Request {
} }
} }
pub fn get_mailboxes(conn: &JmapConnection) -> Result<FnvHashMap<MailboxHash, JmapMailbox>> { pub fn get_mailboxes(conn: &JmapConnection) -> Result<HashMap<MailboxHash, JmapMailbox>> {
let seq = get_request_no!(conn.request_no); let seq = get_request_no!(conn.request_no);
let res = conn let res = conn
.client .client

View File

@ -34,10 +34,10 @@ extern crate notify;
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::time::Duration; use std::time::Duration;
use fnv::{FnvHashMap, FnvHashSet, FnvHasher}; use std::collections::{HashMap, HashSet, hash_map::DefaultHasher};
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs; use std::fs;
use std::hash::{Hash, Hasher}; use std::hash::{Hasher, Hash};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
@ -87,31 +87,31 @@ impl From<PathBuf> for MaildirPath {
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct HashIndex { pub struct HashIndex {
index: FnvHashMap<EnvelopeHash, MaildirPath>, index: HashMap<EnvelopeHash, MaildirPath>,
hash: MailboxHash, hash: MailboxHash,
} }
impl Deref for HashIndex { impl Deref for HashIndex {
type Target = FnvHashMap<EnvelopeHash, MaildirPath>; type Target = HashMap<EnvelopeHash, MaildirPath>;
fn deref(&self) -> &FnvHashMap<EnvelopeHash, MaildirPath> { fn deref(&self) -> &HashMap<EnvelopeHash, MaildirPath> {
&self.index &self.index
} }
} }
impl DerefMut for HashIndex { impl DerefMut for HashIndex {
fn deref_mut(&mut self) -> &mut FnvHashMap<EnvelopeHash, MaildirPath> { fn deref_mut(&mut self) -> &mut HashMap<EnvelopeHash, MaildirPath> {
&mut self.index &mut self.index
} }
} }
pub type HashIndexes = Arc<Mutex<FnvHashMap<MailboxHash, HashIndex>>>; pub type HashIndexes = Arc<Mutex<HashMap<MailboxHash, HashIndex>>>;
/// Maildir backend https://cr.yp.to/proto/maildir.html /// Maildir backend https://cr.yp.to/proto/maildir.html
#[derive(Debug)] #[derive(Debug)]
pub struct MaildirType { pub struct MaildirType {
name: String, name: String,
mailboxes: FnvHashMap<MailboxHash, MaildirMailbox>, mailboxes: HashMap<MailboxHash, MaildirMailbox>,
mailbox_index: Arc<Mutex<FnvHashMap<EnvelopeHash, MailboxHash>>>, mailbox_index: Arc<Mutex<HashMap<EnvelopeHash, MailboxHash>>>,
hash_indexes: HashIndexes, hash_indexes: HashIndexes,
path: PathBuf, 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())); let mut f = fs::File::open(&file).unwrap_or_else(|_| panic!("Can't open {}", file.display()));
f.read_to_end(&mut buf) f.read_to_end(&mut buf)
.unwrap_or_else(|_| panic!("Can't read {}", file.display())); .unwrap_or_else(|_| panic!("Can't read {}", file.display()));
let mut hasher = FnvHasher::default(); let mut hasher = DefaultHasher::default();
hasher.write(&buf); hasher.write(&buf);
hasher.finish() hasher.finish()
*/ */
let mut hasher = FnvHasher::default(); let mut hasher = DefaultHasher::default();
file.hash(&mut hasher); file.hash(&mut hasher);
hasher.finish() hasher.finish()
} }
@ -181,7 +181,7 @@ impl MailBackend for MaildirType {
Ok(()) Ok(())
} }
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> { fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
Ok(self Ok(self
.mailboxes .mailboxes
.iter() .iter()
@ -238,7 +238,7 @@ impl MailBackend for MaildirType {
let mut current_hashes = { let mut current_hashes = {
let mut map = map.lock().unwrap(); let mut map = map.lock().unwrap();
let map = map.entry(mailbox_hash).or_default(); let map = map.entry(mailbox_hash).or_default();
map.keys().cloned().collect::<FnvHashSet<EnvelopeHash>>() map.keys().cloned().collect::<HashSet<EnvelopeHash>>()
}; };
for file in files { for file in files {
let hash = get_file_hash(&file); let hash = get_file_hash(&file);
@ -324,7 +324,7 @@ impl MailBackend for MaildirType {
.mailboxes .mailboxes
.iter() .iter()
.map(|(&k, v)| (k, (v.unseen.clone(), v.total.clone()))) .map(|(&k, v)| (k, (v.unseen.clone(), v.total.clone())))
.collect::<FnvHashMap<MailboxHash, (Arc<Mutex<usize>>, Arc<Mutex<usize>>)>>(); .collect::<HashMap<MailboxHash, (Arc<Mutex<usize>>, Arc<Mutex<usize>>)>>();
let handle = thread::Builder::new() let handle = thread::Builder::new()
.name("mailbox watch".to_string()) .name("mailbox watch".to_string())
.spawn(move || { .spawn(move || {
@ -655,7 +655,7 @@ impl MailBackend for MaildirType {
fn create_mailbox( fn create_mailbox(
&mut self, &mut self,
new_path: String, new_path: String,
) -> Result<(MailboxHash, FnvHashMap<MailboxHash, Mailbox>)> { ) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
let mut path = self.path.clone(); let mut path = self.path.clone();
path.push(&new_path); path.push(&new_path);
if !path.starts_with(&self.path) { if !path.starts_with(&self.path) {
@ -700,7 +700,7 @@ impl MailBackend for MaildirType {
fn delete_mailbox( fn delete_mailbox(
&mut self, &mut self,
_mailbox_hash: MailboxHash, _mailbox_hash: MailboxHash,
) -> Result<FnvHashMap<MailboxHash, Mailbox>> { ) -> Result<HashMap<MailboxHash, Mailbox>> {
Err(MeliError::new("Unimplemented.")) Err(MeliError::new("Unimplemented."))
} }
@ -726,9 +726,9 @@ impl MaildirType {
settings: &AccountSettings, settings: &AccountSettings,
is_subscribed: Box<dyn Fn(&str) -> bool>, is_subscribed: Box<dyn Fn(&str) -> bool>,
) -> Result<Box<dyn MailBackend>> { ) -> Result<Box<dyn MailBackend>> {
let mut mailboxes: FnvHashMap<MailboxHash, MaildirMailbox> = Default::default(); let mut mailboxes: HashMap<MailboxHash, MaildirMailbox> = Default::default();
fn recurse_mailboxes<P: AsRef<Path>>( fn recurse_mailboxes<P: AsRef<Path>>(
mailboxes: &mut FnvHashMap<MailboxHash, MaildirMailbox>, mailboxes: &mut HashMap<MailboxHash, MaildirMailbox>,
settings: &AccountSettings, settings: &AccountSettings,
p: P, p: P,
) -> Result<Vec<MailboxHash>> { ) -> Result<Vec<MailboxHash>> {
@ -820,12 +820,12 @@ impl MaildirType {
} }
let mut hash_indexes = 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() { for &fh in mailboxes.keys() {
hash_indexes.insert( hash_indexes.insert(
fh, fh,
HashIndex { HashIndex {
index: FnvHashMap::with_capacity_and_hasher(0, Default::default()), index: HashMap::with_capacity_and_hasher(0, Default::default()),
hash: fh, hash: fh,
}, },
); );

View File

@ -36,12 +36,12 @@ use crate::email::*;
use crate::error::{MeliError, Result}; use crate::error::{MeliError, Result};
use crate::get_path_hash; use crate::get_path_hash;
use crate::shellexpand::ShellExpandTrait; use crate::shellexpand::ShellExpandTrait;
use fnv::FnvHashMap;
use libc; use libc;
use memmap::{Mmap, Protection}; use memmap::{Mmap, Protection};
use nom::{IResult, Needed}; use nom::{IResult, Needed};
extern crate notify; extern crate notify;
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io::BufReader; use std::io::BufReader;
use std::io::Read; use std::io::Read;
@ -269,7 +269,7 @@ impl BackendOp for MboxOp {
} }
pub fn mbox_parse( pub fn mbox_parse(
index: Arc<Mutex<FnvHashMap<EnvelopeHash, (Offset, Length)>>>, index: Arc<Mutex<HashMap<EnvelopeHash, (Offset, Length)>>>,
input: &[u8], input: &[u8],
file_offset: usize, file_offset: usize,
) -> IResult<&[u8], Vec<Envelope>> { ) -> IResult<&[u8], Vec<Envelope>> {
@ -387,8 +387,8 @@ pub fn mbox_parse(
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct MboxType { pub struct MboxType {
path: PathBuf, path: PathBuf,
index: Arc<Mutex<FnvHashMap<EnvelopeHash, (Offset, Length)>>>, index: Arc<Mutex<HashMap<EnvelopeHash, (Offset, Length)>>>,
mailboxes: Arc<Mutex<FnvHashMap<MailboxHash, MboxMailbox>>>, mailboxes: Arc<Mutex<HashMap<MailboxHash, MboxMailbox>>>,
} }
impl MailBackend for MboxType { impl MailBackend for MboxType {
@ -588,7 +588,7 @@ impl MailBackend for MboxType {
})?; })?;
Ok(handle.thread().id()) Ok(handle.thread().id())
} }
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> { fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
Ok(self Ok(self
.mailboxes .mailboxes
.lock() .lock()

View File

@ -29,10 +29,11 @@ use crate::conf::AccountSettings;
use crate::email::{Envelope, EnvelopeHash, Flag}; use crate::email::{Envelope, EnvelopeHash, Flag};
use crate::error::{MeliError, Result}; use crate::error::{MeliError, Result};
use crate::shellexpand::ShellExpandTrait; use crate::shellexpand::ShellExpandTrait;
use fnv::FnvHashMap;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::hash_map::DefaultHasher; use std::collections::{
use std::collections::BTreeMap; hash_map::{DefaultHasher, HashMap},
BTreeMap,
};
use std::error::Error; use std::error::Error;
use std::ffi::{CStr, CString, OsStr}; use std::ffi::{CStr, CString, OsStr};
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
@ -104,8 +105,8 @@ impl Drop for DbConnection {
pub struct NotmuchDb { pub struct NotmuchDb {
lib: Arc<libloading::Library>, lib: Arc<libloading::Library>,
revision_uuid: Arc<RwLock<u64>>, revision_uuid: Arc<RwLock<u64>>,
mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, NotmuchMailbox>>>, mailboxes: Arc<RwLock<HashMap<MailboxHash, NotmuchMailbox>>>,
index: Arc<RwLock<FnvHashMap<EnvelopeHash, CString>>>, index: Arc<RwLock<HashMap<EnvelopeHash, CString>>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>, tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
path: PathBuf, path: PathBuf,
save_messages_to: Option<PathBuf>, save_messages_to: Option<PathBuf>,
@ -199,7 +200,7 @@ impl NotmuchDb {
))); )));
} }
let mut mailboxes = FnvHashMap::default(); let mut mailboxes = HashMap::default();
for (k, f) in s.mailboxes.iter() { for (k, f) in s.mailboxes.iter() {
if let Some(query_str) = f.extra.get("query") { if let Some(query_str) = f.extra.get("query") {
let hash = { let hash = {
@ -490,7 +491,7 @@ impl MailBackend for NotmuchDb {
})?; })?;
Ok(handle.thread().id()) Ok(handle.thread().id())
} }
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> { fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
Ok(self Ok(self
.mailboxes .mailboxes
.read() .read()
@ -533,7 +534,7 @@ impl MailBackend for NotmuchDb {
#[derive(Debug)] #[derive(Debug)]
struct NotmuchOp { struct NotmuchOp {
hash: EnvelopeHash, hash: EnvelopeHash,
index: Arc<RwLock<FnvHashMap<EnvelopeHash, CString>>>, index: Arc<RwLock<HashMap<EnvelopeHash, CString>>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>, tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
database: Arc<DbConnection>, database: Arc<DbConnection>,
bytes: Option<String>, bytes: Option<String>,

View File

@ -27,10 +27,10 @@ use std::collections::BTreeMap;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
use fnv::{FnvHashMap, FnvHashSet}; use std::collections::{HashMap, HashSet};
pub struct EnvelopeRef<'g> { pub struct EnvelopeRef<'g> {
guard: RwLockReadGuard<'g, FnvHashMap<EnvelopeHash, Envelope>>, guard: RwLockReadGuard<'g, HashMap<EnvelopeHash, Envelope>>,
env_hash: EnvelopeHash, env_hash: EnvelopeHash,
} }
@ -43,7 +43,7 @@ impl Deref for EnvelopeRef<'_> {
} }
pub struct EnvelopeRefMut<'g> { pub struct EnvelopeRefMut<'g> {
guard: RwLockWriteGuard<'g, FnvHashMap<EnvelopeHash, Envelope>>, guard: RwLockWriteGuard<'g, HashMap<EnvelopeHash, Envelope>>,
env_hash: EnvelopeHash, env_hash: EnvelopeHash,
} }
@ -63,13 +63,13 @@ impl DerefMut for EnvelopeRefMut<'_> {
#[derive(Debug, Clone, Deserialize, Default, Serialize)] #[derive(Debug, Clone, Deserialize, Default, Serialize)]
pub struct Collection { pub struct Collection {
pub envelopes: Arc<RwLock<FnvHashMap<EnvelopeHash, Envelope>>>, pub envelopes: Arc<RwLock<HashMap<EnvelopeHash, Envelope>>>,
message_ids: FnvHashMap<Vec<u8>, EnvelopeHash>, message_ids: HashMap<Vec<u8>, EnvelopeHash>,
date_index: BTreeMap<UnixTimestamp, EnvelopeHash>, date_index: BTreeMap<UnixTimestamp, EnvelopeHash>,
subject_index: Option<BTreeMap<String, EnvelopeHash>>, subject_index: Option<BTreeMap<String, EnvelopeHash>>,
pub threads: FnvHashMap<MailboxHash, Threads>, pub threads: HashMap<MailboxHash, Threads>,
sent_mailbox: Option<MailboxHash>, sent_mailbox: Option<MailboxHash>,
pub mailboxes: FnvHashMap<MailboxHash, FnvHashSet<EnvelopeHash>>, pub mailboxes: HashMap<MailboxHash, HashSet<EnvelopeHash>>,
} }
impl Drop for Collection { impl Drop for Collection {
@ -93,17 +93,17 @@ impl Drop for Collection {
} }
impl Collection { impl Collection {
pub fn new(envelopes: FnvHashMap<EnvelopeHash, Envelope>) -> Collection { pub fn new(envelopes: HashMap<EnvelopeHash, Envelope>) -> Collection {
let date_index = BTreeMap::new(); let date_index = BTreeMap::new();
let subject_index = None; 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 /* 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 * thread nodes that shouldn't exist anymore (e.g. because their file moved from /new to
* /cur, or it was deleted). * /cur, or it was deleted).
*/ */
let threads = FnvHashMap::with_capacity_and_hasher(16, Default::default()); let threads = HashMap::with_capacity_and_hasher(16, Default::default());
let mailboxes = FnvHashMap::with_capacity_and_hasher(16, Default::default()); let mailboxes = HashMap::with_capacity_and_hasher(16, Default::default());
Collection { Collection {
envelopes: Arc::new(RwLock::new(envelopes)), envelopes: Arc::new(RwLock::new(envelopes)),
@ -190,7 +190,7 @@ impl Collection {
/// Returns a list of already existing mailboxs whose threads were updated /// Returns a list of already existing mailboxs whose threads were updated
pub fn merge( pub fn merge(
&mut self, &mut self,
mut new_envelopes: FnvHashMap<EnvelopeHash, Envelope>, mut new_envelopes: HashMap<EnvelopeHash, Envelope>,
mailbox_hash: MailboxHash, mailbox_hash: MailboxHash,
sent_mailbox: Option<MailboxHash>, sent_mailbox: Option<MailboxHash>,
) -> Option<SmallVec<[MailboxHash; 8]>> { ) -> Option<SmallVec<[MailboxHash; 8]>> {
@ -407,14 +407,14 @@ impl Collection {
} }
impl Index<&MailboxHash> for Collection { impl Index<&MailboxHash> for Collection {
type Output = FnvHashSet<EnvelopeHash>; type Output = HashSet<EnvelopeHash>;
fn index(&self, index: &MailboxHash) -> &FnvHashSet<EnvelopeHash> { fn index(&self, index: &MailboxHash) -> &HashSet<EnvelopeHash> {
&self.mailboxes[index] &self.mailboxes[index]
} }
} }
impl IndexMut<&MailboxHash> for Collection { impl IndexMut<&MailboxHash> for Collection {
fn index_mut(&mut self, index: &MailboxHash) -> &mut FnvHashSet<EnvelopeHash> { fn index_mut(&mut self, index: &MailboxHash) -> &mut HashSet<EnvelopeHash> {
self.mailboxes.get_mut(index).unwrap() self.mailboxes.get_mut(index).unwrap()
} }
} }

View File

@ -22,7 +22,7 @@
/*! /*!
* Email parsing, handling, sending etc. * Email parsing, handling, sending etc.
*/ */
use fnv::FnvHashMap; use std::collections::HashMap;
mod compose; mod compose;
pub use self::compose::*; pub use self::compose::*;
@ -138,7 +138,7 @@ pub struct Envelope {
message_id: MessageID, message_id: MessageID,
in_reply_to: Option<MessageID>, in_reply_to: Option<MessageID>,
pub references: Option<References>, pub references: Option<References>,
other_headers: FnvHashMap<String, String>, other_headers: HashMap<String, String>,
timestamp: UnixTimestamp, timestamp: UnixTimestamp,
thread: ThreadNodeHash, thread: ThreadNodeHash,
@ -577,11 +577,11 @@ impl Envelope {
} }
} }
pub fn other_headers(&self) -> &FnvHashMap<String, String> { pub fn other_headers(&self) -> &HashMap<String, String> {
&self.other_headers &self.other_headers
} }
pub fn other_headers_mut(&mut self) -> &mut FnvHashMap<String, String> { pub fn other_headers_mut(&mut self) -> &mut HashMap<String, String> {
&mut self.other_headers &mut self.other_headers
} }

View File

@ -24,6 +24,7 @@ use crate::backends::BackendOp;
use crate::email::attachments::AttachmentBuilder; use crate::email::attachments::AttachmentBuilder;
use crate::shellexpand::ShellExpandTrait; use crate::shellexpand::ShellExpandTrait;
use data_encoding::BASE64_MIME; use data_encoding::BASE64_MIME;
use std::collections::HashMap;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::io::Read; use std::io::Read;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -35,11 +36,10 @@ pub mod random;
//use self::mime::*; //use self::mime::*;
use super::parser; use super::parser;
use fnv::FnvHashMap;
#[derive(Debug, PartialEq, Eq, Clone)] #[derive(Debug, PartialEq, Eq, Clone)]
pub struct Draft { pub struct Draft {
pub headers: FnvHashMap<String, String>, pub headers: HashMap<String, String>,
pub header_order: Vec<String>, pub header_order: Vec<String>,
pub body: String, pub body: String,
@ -48,7 +48,7 @@ pub struct Draft {
impl Default for Draft { impl Default for Draft {
fn default() -> Self { 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); let mut header_order = Vec::with_capacity(8);
headers.insert("From".into(), "".into()); headers.insert("From".into(), "".into());
headers.insert("To".into(), "".into()); headers.insert("To".into(), "".into());
@ -214,11 +214,11 @@ impl Draft {
ret ret
} }
pub fn headers_mut(&mut self) -> &mut FnvHashMap<String, String> { pub fn headers_mut(&mut self) -> &mut HashMap<String, String> {
&mut self.headers &mut self.headers
} }
pub fn headers(&self) -> &FnvHashMap<String, String> { pub fn headers(&self) -> &HashMap<String, String> {
&self.headers &self.headers
} }

View File

@ -135,7 +135,6 @@ extern crate encoding;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
extern crate fnv;
extern crate uuid; extern crate uuid;
pub use smallvec; pub use smallvec;

View File

@ -43,9 +43,9 @@ pub use iterators::*;
use crate::text_processing::grapheme_clusters::*; use crate::text_processing::grapheme_clusters::*;
use uuid::Uuid; use uuid::Uuid;
use fnv::{FnvHashMap, FnvHashSet};
use std::cell::RefCell; use std::cell::RefCell;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
use std::fmt; use std::fmt;
use std::iter::FromIterator; use std::iter::FromIterator;
use std::ops::Index; use std::ops::Index;
@ -56,7 +56,7 @@ use std::sync::{Arc, RwLock};
use smallvec::SmallVec; use smallvec::SmallVec;
type Envelopes = Arc<RwLock<FnvHashMap<EnvelopeHash, Envelope>>>; type Envelopes = Arc<RwLock<HashMap<EnvelopeHash, Envelope>>>;
macro_rules! uuid_hash_type { macro_rules! uuid_hash_type {
($n:ident) => { ($n:ident) => {
@ -407,15 +407,15 @@ impl ThreadNode {
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Threads { pub struct Threads {
pub thread_nodes: FnvHashMap<ThreadNodeHash, ThreadNode>, pub thread_nodes: HashMap<ThreadNodeHash, ThreadNode>,
root_set: RefCell<Vec<ThreadNodeHash>>, root_set: RefCell<Vec<ThreadNodeHash>>,
tree_index: RefCell<Vec<ThreadNodeHash>>, tree_index: RefCell<Vec<ThreadNodeHash>>,
pub groups: FnvHashMap<ThreadHash, ThreadGroup>, pub groups: HashMap<ThreadHash, ThreadGroup>,
message_ids: FnvHashMap<Vec<u8>, ThreadNodeHash>, message_ids: HashMap<Vec<u8>, ThreadNodeHash>,
pub message_ids_set: FnvHashSet<Vec<u8>>, pub message_ids_set: HashSet<Vec<u8>>,
pub missing_message_ids: FnvHashSet<Vec<u8>>, pub missing_message_ids: HashSet<Vec<u8>>,
pub hash_set: FnvHashSet<EnvelopeHash>, pub hash_set: HashSet<EnvelopeHash>,
sort: RefCell<(SortField, SortOrder)>, sort: RefCell<(SortField, SortOrder)>,
subsort: RefCell<(SortField, SortOrder)>, subsort: RefCell<(SortField, SortOrder)>,
} }
@ -468,22 +468,19 @@ impl Threads {
/* To reconstruct thread information from the mails we need: */ /* To reconstruct thread information from the mails we need: */
/* a vector to hold thread members */ /* a vector to hold thread members */
let thread_nodes: FnvHashMap<ThreadNodeHash, ThreadNode> = let thread_nodes: HashMap<ThreadNodeHash, ThreadNode> =
FnvHashMap::with_capacity_and_hasher( HashMap::with_capacity_and_hasher((length as f64 * 1.2) as usize, Default::default());
(length as f64 * 1.2) as usize,
Default::default(),
);
/* A hash table of Message IDs */ /* A hash table of Message IDs */
let message_ids: FnvHashMap<Vec<u8>, ThreadNodeHash> = let message_ids: HashMap<Vec<u8>, ThreadNodeHash> =
FnvHashMap::with_capacity_and_hasher(length, Default::default()); HashMap::with_capacity_and_hasher(length, Default::default());
/* A hash set of Message IDs we haven't encountered yet as an Envelope */ /* A hash set of Message IDs we haven't encountered yet as an Envelope */
let missing_message_ids: FnvHashSet<Vec<u8>> = let missing_message_ids: HashSet<Vec<u8>> =
FnvHashSet::with_capacity_and_hasher(length, Default::default()); HashSet::with_capacity_and_hasher(length, Default::default());
/* A hash set of Message IDs we have encountered as a MessageID */ /* A hash set of Message IDs we have encountered as a MessageID */
let message_ids_set: FnvHashSet<Vec<u8>> = let message_ids_set: HashSet<Vec<u8>> =
FnvHashSet::with_capacity_and_hasher(length, Default::default()); HashSet::with_capacity_and_hasher(length, Default::default());
let hash_set: FnvHashSet<EnvelopeHash> = let hash_set: HashSet<EnvelopeHash> =
FnvHashSet::with_capacity_and_hasher(length, Default::default()); HashSet::with_capacity_and_hasher(length, Default::default());
Threads { Threads {
thread_nodes, thread_nodes,
@ -582,7 +579,7 @@ impl Threads {
pub fn amend(&mut self, envelopes: &mut Envelopes) { pub fn amend(&mut self, envelopes: &mut Envelopes) {
let envelopes_lck = envelopes.read().unwrap(); 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<EnvelopeHash> = let difference: Vec<EnvelopeHash> =
self.hash_set.difference(&new_hash_set).cloned().collect(); self.hash_set.difference(&new_hash_set).cloned().collect();
@ -831,7 +828,7 @@ impl Threads {
.message_ids .message_ids
.iter() .iter()
.map(|(a, &b)| (b, a.to_vec())) .map(|(a, &b)| (b, a.to_vec()))
.collect::<FnvHashMap<ThreadNodeHash, Vec<u8>>>(), .collect::<HashMap<ThreadNodeHash, Vec<u8>>>(),
&envelopes, &envelopes,
); );
*/ */
@ -1168,7 +1165,7 @@ impl Threads {
thread.message().unwrap() thread.message().unwrap()
} }
pub fn thread_nodes(&self) -> &FnvHashMap<ThreadNodeHash, ThreadNode> { pub fn thread_nodes(&self) -> &HashMap<ThreadNodeHash, ThreadNode> {
&self.thread_nodes &self.thread_nodes
} }
@ -1206,13 +1203,13 @@ impl Index<&ThreadNodeHash> for Threads {
/* /*
fn print_threadnodes( fn print_threadnodes(
node_hash: ThreadNodeHash, node_hash: ThreadNodeHash,
nodes: &FnvHashMap<ThreadNodeHash, ThreadNode>, nodes: &HashMap<ThreadNodeHash, ThreadNode>,
envelopes: &Envelopes, envelopes: &Envelopes,
) { ) {
fn help( fn help(
level: usize, level: usize,
node_hash: ThreadNodeHash, node_hash: ThreadNodeHash,
nodes: &FnvHashMap<ThreadNodeHash, ThreadNode>, nodes: &HashMap<ThreadNodeHash, ThreadNode>,
envelopes: &Envelopes, envelopes: &Envelopes,
) { ) {
eprint!("{}ThreadNode {}\n{}\tmessage: {}\n{}\tparent: {}\n{}\tthread_group: {}\n{}\tchildren (len: {}):\n", eprint!("{}ThreadNode {}\n{}\tmessage: {}\n{}\tparent: {}\n{}\tthread_group: {}\n{}\tchildren (len: {}):\n",
@ -1261,8 +1258,8 @@ struct Graph {
/* /*
fn save_graph( fn save_graph(
node_arr: &[ThreadNodeHash], node_arr: &[ThreadNodeHash],
nodes: &FnvHashMap<ThreadNodeHash, ThreadNode>, nodes: &HashMap<ThreadNodeHash, ThreadNode>,
ids: &FnvHashMap<ThreadNodeHash, Vec<u8>>, ids: &HashMap<ThreadNodeHash, Vec<u8>>,
envelopes: &Envelopes, envelopes: &Envelopes,
) { ) {
let envelopes = envelopes.read().unwrap(); let envelopes = envelopes.read().unwrap();

View File

@ -20,8 +20,8 @@
*/ */
use super::{ThreadNode, ThreadNodeHash}; use super::{ThreadNode, ThreadNodeHash};
use fnv::FnvHashMap;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::HashMap;
/* `ThreadsIterator` returns messages according to the sorted order. For example, for the following /* `ThreadsIterator` returns messages according to the sorted order. For example, for the following
* threads: * threads:
@ -42,7 +42,7 @@ pub struct ThreadsGroupIterator<'a> {
pub(super) root_tree: SmallVec<[ThreadNodeHash; 1024]>, pub(super) root_tree: SmallVec<[ThreadNodeHash; 1024]>,
pub(super) pos: usize, pub(super) pos: usize,
pub(super) stack: SmallVec<[usize; 16]>, pub(super) stack: SmallVec<[usize; 16]>,
pub(super) thread_nodes: &'a FnvHashMap<ThreadNodeHash, ThreadNode>, pub(super) thread_nodes: &'a HashMap<ThreadNodeHash, ThreadNode>,
} }
impl<'a> Iterator for ThreadsGroupIterator<'a> { impl<'a> Iterator for ThreadsGroupIterator<'a> {
type Item = (usize, ThreadNodeHash, bool); type Item = (usize, ThreadNodeHash, bool);
@ -100,7 +100,7 @@ pub struct ThreadGroupIterator<'a> {
pub(super) group: ThreadNodeHash, pub(super) group: ThreadNodeHash,
pub(super) pos: usize, pub(super) pos: usize,
pub(super) stack: SmallVec<[usize; 16]>, pub(super) stack: SmallVec<[usize; 16]>,
pub(super) thread_nodes: &'a FnvHashMap<ThreadNodeHash, ThreadNode>, pub(super) thread_nodes: &'a HashMap<ThreadNodeHash, ThreadNode>,
} }
impl<'a> Iterator for ThreadGroupIterator<'a> { impl<'a> Iterator for ThreadGroupIterator<'a> {

View File

@ -37,7 +37,6 @@ extern crate serde_derive;
extern crate linkify; extern crate linkify;
extern crate uuid; extern crate uuid;
extern crate fnv;
extern crate termion; extern crate termion;
#[macro_use] #[macro_use]

View File

@ -43,15 +43,15 @@ pub use crate::contacts::*;
use std::fmt; use std::fmt;
use std::fmt::{Debug, Display}; use std::fmt::{Debug, Display};
use fnv::FnvHashMap; use std::collections::HashMap;
use uuid::Uuid; use uuid::Uuid;
use super::{Key, StatusEvent, UIEvent}; use super::{Key, StatusEvent, UIEvent};
pub type ComponentId = Uuid; pub type ComponentId = Uuid;
pub type ShortcutMap = FnvHashMap<&'static str, Key>; pub type ShortcutMap = HashMap<&'static str, Key>;
pub type ShortcutMaps = FnvHashMap<&'static str, ShortcutMap>; pub type ShortcutMaps = HashMap<&'static str, ShortcutMap>;
/// Types implementing this Trait can draw on the terminal and receive events. /// 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 /// If a type wants to skip drawing if it has not changed anything, it can hold some flag in its

View File

@ -20,7 +20,7 @@
*/ */
use super::*; use super::*;
use fnv::FnvHashMap; use std::collections::HashMap;
mod contact_list; mod contact_list;
@ -205,7 +205,7 @@ impl Component for ContactManager {
let fields = std::mem::replace(&mut self.form, FormWidget::default()) let fields = std::mem::replace(&mut self.form, FormWidget::default())
.collect() .collect()
.unwrap(); .unwrap();
let fields: FnvHashMap<String, String> = fields let fields: HashMap<String, String> = fields
.into_iter() .into_iter()
.map(|(s, v)| { .map(|(s, v)| {
( (

View File

@ -22,6 +22,7 @@
use super::*; use super::*;
use crate::types::segment_tree::SegmentTree; use crate::types::segment_tree::SegmentTree;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::{HashMap, HashSet};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
mod conversations; mod conversations;
@ -1149,7 +1150,7 @@ impl Listing {
debug!("BUG: invalid area in print_account"); debug!("BUG: invalid area in print_account");
} }
// Each entry and its index in the account // Each entry and its index in the account
let mailboxes: FnvHashMap<MailboxHash, Mailbox> = context.accounts[a.index] let mailboxes: HashMap<MailboxHash, Mailbox> = context.accounts[a.index]
.mailbox_entries .mailbox_entries
.iter() .iter()
.map(|(&hash, entry)| (hash, entry.ref_mailbox.clone())) .map(|(&hash, entry)| (hash, entry.ref_mailbox.clone()))

View File

@ -54,15 +54,15 @@ pub struct CompactListing {
length: usize, length: usize,
sort: (SortField, SortOrder), sort: (SortField, SortOrder),
subsort: (SortField, SortOrder), subsort: (SortField, SortOrder),
all_threads: fnv::FnvHashSet<ThreadHash>, all_threads: HashSet<ThreadHash>,
order: FnvHashMap<ThreadHash, usize>, order: HashMap<ThreadHash, usize>,
/// Cache current view. /// Cache current view.
data_columns: DataColumns, data_columns: DataColumns,
filter_term: String, filter_term: String,
filtered_selection: Vec<ThreadHash>, filtered_selection: Vec<ThreadHash>,
filtered_order: FnvHashMap<ThreadHash, usize>, filtered_order: HashMap<ThreadHash, usize>,
selection: FnvHashMap<ThreadHash, bool>, selection: HashMap<ThreadHash, bool>,
/// If we must redraw on next redraw event /// If we must redraw on next redraw event
dirty: bool, dirty: bool,
force_draw: bool, force_draw: bool,
@ -661,12 +661,12 @@ impl CompactListing {
length: 0, length: 0,
sort: (Default::default(), Default::default()), sort: (Default::default(), Default::default()),
subsort: (SortField::Date, SortOrder::Desc), subsort: (SortField::Date, SortOrder::Desc),
all_threads: fnv::FnvHashSet::default(), all_threads: HashSet::default(),
order: FnvHashMap::default(), order: HashMap::default(),
filter_term: String::new(), filter_term: String::new(),
filtered_selection: Vec::new(), filtered_selection: Vec::new(),
filtered_order: FnvHashMap::default(), filtered_order: HashMap::default(),
selection: FnvHashMap::default(), selection: HashMap::default(),
row_updates: SmallVec::new(), row_updates: SmallVec::new(),
data_columns: DataColumns::default(), data_columns: DataColumns::default(),
dirty: true, dirty: true,

View File

@ -33,15 +33,15 @@ pub struct ConversationsListing {
length: usize, length: usize,
sort: (SortField, SortOrder), sort: (SortField, SortOrder),
subsort: (SortField, SortOrder), subsort: (SortField, SortOrder),
all_threads: fnv::FnvHashSet<ThreadHash>, all_threads: HashSet<ThreadHash>,
order: FnvHashMap<ThreadHash, usize>, order: HashMap<ThreadHash, usize>,
/// Cache current view. /// Cache current view.
content: CellBuffer, content: CellBuffer,
filter_term: String, filter_term: String,
filtered_selection: Vec<ThreadHash>, filtered_selection: Vec<ThreadHash>,
filtered_order: FnvHashMap<ThreadHash, usize>, filtered_order: HashMap<ThreadHash, usize>,
selection: FnvHashMap<ThreadHash, bool>, selection: HashMap<ThreadHash, bool>,
/// If we must redraw on next redraw event /// If we must redraw on next redraw event
dirty: bool, dirty: bool,
force_draw: bool, force_draw: bool,
@ -568,12 +568,12 @@ impl ConversationsListing {
length: 0, length: 0,
sort: (Default::default(), Default::default()), sort: (Default::default(), Default::default()),
subsort: (SortField::Date, SortOrder::Desc), subsort: (SortField::Date, SortOrder::Desc),
order: FnvHashMap::default(), order: HashMap::default(),
all_threads: fnv::FnvHashSet::default(), all_threads: HashSet::default(),
filter_term: String::new(), filter_term: String::new(),
filtered_selection: Vec::new(), filtered_selection: Vec::new(),
filtered_order: FnvHashMap::default(), filtered_order: HashMap::default(),
selection: FnvHashMap::default(), selection: HashMap::default(),
row_updates: SmallVec::new(), row_updates: SmallVec::new(),
content: Default::default(), content: Default::default(),
dirty: true, dirty: true,

View File

@ -53,16 +53,16 @@ pub struct PlainListing {
length: usize, length: usize,
sort: (SortField, SortOrder), sort: (SortField, SortOrder),
subsort: (SortField, SortOrder), subsort: (SortField, SortOrder),
all_envelopes: fnv::FnvHashSet<EnvelopeHash>, all_envelopes: HashSet<EnvelopeHash>,
order: FnvHashMap<EnvelopeHash, usize>, order: HashMap<EnvelopeHash, usize>,
/// Cache current view. /// Cache current view.
data_columns: DataColumns, data_columns: DataColumns,
filter_term: String, filter_term: String,
filtered_selection: Vec<EnvelopeHash>, filtered_selection: Vec<EnvelopeHash>,
filtered_order: FnvHashMap<EnvelopeHash, usize>, filtered_order: HashMap<EnvelopeHash, usize>,
selection: FnvHashMap<EnvelopeHash, bool>, selection: HashMap<EnvelopeHash, bool>,
thread_node_hashes: FnvHashMap<EnvelopeHash, ThreadNodeHash>, thread_node_hashes: HashMap<EnvelopeHash, ThreadNodeHash>,
local_collection: Vec<EnvelopeHash>, local_collection: Vec<EnvelopeHash>,
/// If we must redraw on next redraw event /// If we must redraw on next redraw event
dirty: bool, dirty: bool,
@ -627,14 +627,14 @@ impl PlainListing {
length: 0, length: 0,
sort: (Default::default(), Default::default()), sort: (Default::default(), Default::default()),
subsort: (SortField::Date, SortOrder::Desc), subsort: (SortField::Date, SortOrder::Desc),
all_envelopes: fnv::FnvHashSet::default(), all_envelopes: HashSet::default(),
local_collection: Vec::new(), local_collection: Vec::new(),
thread_node_hashes: FnvHashMap::default(), thread_node_hashes: HashMap::default(),
order: FnvHashMap::default(), order: HashMap::default(),
filter_term: String::new(), filter_term: String::new(),
filtered_selection: Vec::new(), filtered_selection: Vec::new(),
filtered_order: FnvHashMap::default(), filtered_order: HashMap::default(),
selection: FnvHashMap::default(), selection: HashMap::default(),
row_updates: SmallVec::new(), row_updates: SmallVec::new(),
_row_updates: SmallVec::new(), _row_updates: SmallVec::new(),
data_columns: DataColumns::default(), data_columns: DataColumns::default(),

View File

@ -39,7 +39,7 @@ pub struct ThreadListing {
color_cache: ColorCache, color_cache: ColorCache,
row_updates: SmallVec<[ThreadHash; 8]>, row_updates: SmallVec<[ThreadHash; 8]>,
order: FnvHashMap<EnvelopeHash, usize>, order: HashMap<EnvelopeHash, usize>,
/// If we must redraw on next redraw event /// If we must redraw on next redraw event
dirty: bool, dirty: bool,
/// If `self.view` is focused or not. /// 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)) .filter_map(|r| threads.groups[&r].root().map(|r| r.root))
.collect::<_>(); .collect::<_>();
let mut iter = threads.threads_group_iter(roots).peekable(); let mut iter = threads.threads_group_iter(roots).peekable();
let thread_nodes: &FnvHashMap<ThreadNodeHash, ThreadNode> = &threads.thread_nodes(); let thread_nodes: &HashMap<ThreadNodeHash, ThreadNode> = &threads.thread_nodes();
/* This is just a desugared for loop so that we can use .peek() */ /* This is just a desugared for loop so that we can use .peek() */
let mut idx = 0; let mut idx = 0;
while let Some((indentation, thread_node_hash, has_sibling)) = iter.next() { 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(' ')), content: CellBuffer::new(0, 0, Cell::with_char(' ')),
color_cache: ColorCache::default(), color_cache: ColorCache::default(),
row_updates: SmallVec::new(), row_updates: SmallVec::new(),
order: FnvHashMap::default(), order: HashMap::default(),
dirty: true, dirty: true,
unfocused: false, unfocused: false,
view: None, view: None,

View File

@ -27,7 +27,7 @@ use text_processing::Reflow;
mod widgets; mod widgets;
pub use self::widgets::*; pub use self::widgets::*;
use fnv::FnvHashSet; use std::collections::HashSet;
/// A horizontally split in half container. /// A horizontally split in half container.
#[derive(Debug)] #[derive(Debug)]
@ -814,8 +814,7 @@ impl Component for Pager {
self.dirty = value; self.dirty = value;
} }
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps { fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let config_map: FnvHashMap<&'static str, Key> = let config_map: HashMap<&'static str, Key> = context.settings.shortcuts.pager.key_values();
context.settings.shortcuts.pager.key_values();
let mut ret: ShortcutMaps = Default::default(); let mut ret: ShortcutMaps = Default::default();
ret.insert(Pager::DESCRIPTION, config_map); ret.insert(Pager::DESCRIPTION, config_map);
ret ret
@ -986,7 +985,7 @@ impl Component for StatusBar {
return; return;
} }
let mut unique_suggestions: FnvHashSet<&str> = FnvHashSet::default(); let mut unique_suggestions: HashSet<&str> = HashSet::default();
let mut suggestions: Vec<AutoCompleteEntry> = self let mut suggestions: Vec<AutoCompleteEntry> = self
.cmd_history .cmd_history
.iter() .iter()

View File

@ -20,7 +20,7 @@
*/ */
use super::*; use super::*;
use fnv::FnvHashMap; use std::collections::HashMap;
type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send + Sync>; type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send + Sync>;
@ -298,7 +298,7 @@ impl fmt::Display for Field {
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct FormWidget { pub struct FormWidget {
fields: FnvHashMap<String, Field>, fields: HashMap<String, Field>,
layout: Vec<String>, layout: Vec<String>,
buttons: ButtonWidget<bool>, buttons: ButtonWidget<bool>,
@ -375,11 +375,11 @@ impl FormWidget {
self.fields.insert(value.0, value.1); self.fields.insert(value.0, value.1);
} }
pub fn values_mut(&mut self) -> &mut FnvHashMap<String, Field> { pub fn values_mut(&mut self) -> &mut HashMap<String, Field> {
&mut self.fields &mut self.fields
} }
pub fn collect(self) -> Option<FnvHashMap<String, Field>> { pub fn collect(self) -> Option<HashMap<String, Field>> {
if let Some(true) = self.buttons_result() { if let Some(true) = self.buttons_result() {
Some(self.fields) Some(self.fields)
} else { } else {
@ -598,7 +598,7 @@ pub struct ButtonWidget<T>
where where
T: 'static + std::fmt::Debug + Default + Send + Sync, T: 'static + std::fmt::Debug + Default + Send + Sync,
{ {
buttons: FnvHashMap<String, T>, buttons: HashMap<String, T>,
layout: Vec<String>, layout: Vec<String>,
result: Option<T>, result: Option<T>,

View File

@ -24,7 +24,6 @@
*/ */
use super::{AccountConf, FileMailboxConf}; use super::{AccountConf, FileMailboxConf};
use fnv::FnvHashMap;
use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext}; use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext};
use melib::backends::{ use melib::backends::{
BackendOp, Backends, MailBackend, Mailbox, MailboxHash, NotifyFn, ReadOnlyOp, RefreshEvent, 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::AddressBook;
use melib::Collection; use melib::Collection;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::HashMap;
use crate::types::UIEvent::{self, EnvelopeRemove, EnvelopeRename, EnvelopeUpdate, Notification}; use crate::types::UIEvent::{self, EnvelopeRemove, EnvelopeRename, EnvelopeUpdate, Notification};
use crate::{StatusEvent, ThreadEvent}; use crate::{StatusEvent, ThreadEvent};
@ -114,7 +114,7 @@ pub struct Account {
pub index: usize, pub index: usize,
name: String, name: String,
pub is_online: bool, pub is_online: bool,
pub(crate) mailbox_entries: FnvHashMap<MailboxHash, MailboxEntry>, pub(crate) mailbox_entries: HashMap<MailboxHash, MailboxEntry>,
pub(crate) mailboxes_order: Vec<MailboxHash>, pub(crate) mailboxes_order: Vec<MailboxHash>,
tree: Vec<MailboxNode>, tree: Vec<MailboxNode>,
sent_mailbox: Option<MailboxHash>, sent_mailbox: Option<MailboxHash>,
@ -251,7 +251,7 @@ impl Account {
} }
fn init(&mut self) { fn init(&mut self) {
let mut ref_mailboxes: FnvHashMap<MailboxHash, Mailbox> = let mut ref_mailboxes: HashMap<MailboxHash, Mailbox> =
match self.backend.read().unwrap().mailboxes() { match self.backend.read().unwrap().mailboxes() {
Ok(f) => f, Ok(f) => f,
Err(err) => { Err(err) => {
@ -259,8 +259,8 @@ impl Account {
return; return;
} }
}; };
let mut mailbox_entries: FnvHashMap<MailboxHash, MailboxEntry> = let mut mailbox_entries: HashMap<MailboxHash, MailboxEntry> =
FnvHashMap::with_capacity_and_hasher(ref_mailboxes.len(), Default::default()); HashMap::with_capacity_and_hasher(ref_mailboxes.len(), Default::default());
let mut mailboxes_order: Vec<MailboxHash> = Vec::with_capacity(ref_mailboxes.len()); let mut mailboxes_order: Vec<MailboxHash> = Vec::with_capacity(ref_mailboxes.len());
let mut sent_mailbox = None; let mut sent_mailbox = None;
@ -775,7 +775,7 @@ impl Account {
.unwrap() .unwrap()
.into_iter() .into_iter()
.map(|e| (e.hash(), e)) .map(|e| (e.hash(), e))
.collect::<FnvHashMap<EnvelopeHash, Envelope>>(); .collect::<HashMap<EnvelopeHash, Envelope>>();
if let Some(updated_mailboxes) = if let Some(updated_mailboxes) =
self.collection self.collection
.merge(envelopes, mailbox_hash, self.sent_mailbox) .merge(envelopes, mailbox_hash, self.sent_mailbox)
@ -1206,7 +1206,7 @@ impl IndexMut<&MailboxHash> for Account {
fn build_mailboxes_order( fn build_mailboxes_order(
tree: &mut Vec<MailboxNode>, tree: &mut Vec<MailboxNode>,
mailbox_entries: &FnvHashMap<MailboxHash, MailboxEntry>, mailbox_entries: &HashMap<MailboxHash, MailboxEntry>,
mailboxes_order: &mut Vec<MailboxHash>, mailboxes_order: &mut Vec<MailboxHash>,
) { ) {
tree.clear(); tree.clear();
@ -1215,7 +1215,7 @@ fn build_mailboxes_order(
if f.ref_mailbox.parent().is_none() { if f.ref_mailbox.parent().is_none() {
fn rec( fn rec(
h: MailboxHash, h: MailboxHash,
mailbox_entries: &FnvHashMap<MailboxHash, MailboxEntry>, mailbox_entries: &HashMap<MailboxHash, MailboxEntry>,
depth: usize, depth: usize,
) -> MailboxNode { ) -> MailboxNode {
let mut node = MailboxNode { let mut node = MailboxNode {

View File

@ -21,7 +21,7 @@
use crate::override_def; use crate::override_def;
use crate::terminal::Key; use crate::terminal::Key;
use fnv::FnvHashMap; use std::collections::HashMap;
#[macro_export] #[macro_export]
macro_rules! shortcut { macro_rules! shortcut {
@ -95,7 +95,7 @@ macro_rules! shortcut_key_values {
} }
} }
/// Returns a hashmap of all shortcuts and their 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()),)* $((stringify!($fname),(self.$fname).clone()),)*
].iter().cloned().collect() ].iter().cloned().collect()

View File

@ -24,10 +24,10 @@
use crate::split_command; use crate::split_command;
use crate::state::Context; use crate::state::Context;
use crate::types::{create_temp_file, ForkType, UIEvent}; use crate::types::{create_temp_file, ForkType, UIEvent};
use fnv::FnvHashMap;
use melib::attachments::decode; use melib::attachments::decode;
use melib::text_processing::GlobMatch; use melib::text_processing::GlobMatch;
use melib::{email::Attachment, MeliError, Result}; use melib::{email::Attachment, MeliError, Result};
use std::collections::HashMap;
use std::io::Read; use std::io::Read;
use std::io::Write; use std::io::Write;
use std::path::PathBuf; 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(); let mut content = String::new();
std::fs::File::open(mailcap_path.as_path())?.read_to_string(&mut content)?; std::fs::File::open(mailcap_path.as_path())?.read_to_string(&mut content)?;

View File

@ -31,7 +31,6 @@ extern crate serde_derive;
extern crate linkify; extern crate linkify;
extern crate uuid; extern crate uuid;
extern crate fnv;
extern crate termion; extern crate termion;
#[macro_use] #[macro_use]

View File

@ -20,7 +20,6 @@
*/ */
use super::*; use super::*;
use fnv::FnvHashMap;
use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext}; use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext};
use melib::backends::MailboxHash; use melib::backends::MailboxHash;
use melib::backends::{Backend, BackendOp, Backends, MailBackend, Mailbox, RefreshEventConsumer}; 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::email::{Envelope, EnvelopeHash, Flag};
use melib::error::{MeliError, Result}; use melib::error::{MeliError, Result};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::HashMap;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
// TODO replace with melib::Envelope after simplifying melib::Envelope's // TODO replace with melib::Envelope after simplifying melib::Envelope's
@ -193,8 +193,8 @@ impl MailBackend for PluginBackend {
Err(MeliError::new("Unimplemented.")) Err(MeliError::new("Unimplemented."))
} }
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> { fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
let mut ret: FnvHashMap<MailboxHash, Mailbox> = Default::default(); let mut ret: HashMap<MailboxHash, Mailbox> = Default::default();
ret.insert(0, Mailbox::default()); ret.insert(0, Mailbox::default());
Ok(ret) Ok(ret)
} }
@ -214,7 +214,7 @@ impl MailBackend for PluginBackend {
fn create_mailbox( fn create_mailbox(
&mut self, &mut self,
_name: String, _name: String,
) -> Result<(MailboxHash, FnvHashMap<MailboxHash, Mailbox>)> { ) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
Err(MeliError::new("Unimplemented.")) Err(MeliError::new("Unimplemented."))
} }
fn tags(&self) -> Option<Arc<RwLock<BTreeMap<u64, String>>>> { fn tags(&self) -> Option<Arc<RwLock<BTreeMap<u64, String>>>> {

View File

@ -33,8 +33,8 @@ use crate::plugins::PluginManager;
use melib::backends::{MailboxHash, NotifyFn}; use melib::backends::{MailboxHash, NotifyFn};
use crossbeam::channel::{unbounded, Receiver, Sender}; use crossbeam::channel::{unbounded, Receiver, Sender};
use fnv::FnvHashMap;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::HashMap;
use std::env; use std::env;
use std::io::Write; use std::io::Write;
use std::thread; use std::thread;
@ -89,7 +89,7 @@ impl InputHandler {
/// A context container for loaded settings, accounts, UI changes, etc. /// A context container for loaded settings, accounts, UI changes, etc.
pub struct Context { pub struct Context {
pub accounts: Vec<Account>, pub accounts: Vec<Account>,
pub mailbox_hashes: FnvHashMap<MailboxHash, usize>, pub mailbox_hashes: HashMap<MailboxHash, usize>,
pub settings: Settings, pub settings: Settings,
pub runtime_settings: Settings, pub runtime_settings: Settings,
@ -315,7 +315,7 @@ impl State {
context: Context { context: Context {
accounts, accounts,
mailbox_hashes: FnvHashMap::with_capacity_and_hasher(1, Default::default()), mailbox_hashes: HashMap::with_capacity_and_hasher(1, Default::default()),
settings: settings.clone(), settings: settings.clone(),
runtime_settings: settings, runtime_settings: settings,

View File

@ -26,10 +26,10 @@ use crossbeam::{
channel::{bounded, unbounded, Sender}, channel::{bounded, unbounded, Sender},
select, select,
}; };
use fnv::FnvHashMap;
use melib::async_workers::{Work, WorkContext}; use melib::async_workers::{Work, WorkContext};
use melib::datetime::{self, UnixTimestamp}; use melib::datetime::{self, UnixTimestamp};
use melib::text_processing::Truncate; use melib::text_processing::Truncate;
use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex; use std::sync::Mutex;
use std::thread; use std::thread;
@ -59,9 +59,9 @@ pub struct WorkController {
pub queue: WorkQueue, pub queue: WorkQueue,
thread_end_tx: Sender<bool>, thread_end_tx: Sender<bool>,
/// Worker threads that take up on jobs from self.queue /// Worker threads that take up on jobs from self.queue
pub threads: Arc<Mutex<FnvHashMap<thread::ThreadId, Worker>>>, pub threads: Arc<Mutex<HashMap<thread::ThreadId, Worker>>>,
/// Special function threads that live indefinitely (eg watching a mailbox) /// Special function threads that live indefinitely (eg watching a mailbox)
pub static_threads: Arc<Mutex<FnvHashMap<thread::ThreadId, Worker>>>, pub static_threads: Arc<Mutex<HashMap<thread::ThreadId, Worker>>>,
work_context: WorkContext, work_context: WorkContext,
} }
@ -177,11 +177,11 @@ impl WorkController {
// Create a SyncFlag to share whether or not there are more jobs to be done. // 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 (thread_end_tx, thread_end_rx) = bounded(1);
let threads_lock: Arc<Mutex<FnvHashMap<thread::ThreadId, Worker>>> = let threads_lock: Arc<Mutex<HashMap<thread::ThreadId, Worker>>> =
Arc::new(Mutex::new(FnvHashMap::default())); Arc::new(Mutex::new(HashMap::default()));
let static_threads_lock: Arc<Mutex<FnvHashMap<thread::ThreadId, Worker>>> = let static_threads_lock: Arc<Mutex<HashMap<thread::ThreadId, Worker>>> =
Arc::new(Mutex::new(FnvHashMap::default())); Arc::new(Mutex::new(HashMap::default()));
let mut threads = threads_lock.lock().unwrap(); let mut threads = threads_lock.lock().unwrap();
/* spawn worker threads */ /* spawn worker threads */