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)",
"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)",

View File

@ -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"

View File

@ -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 }

View File

@ -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<CardId, Card>,
pub cards: HashMap<CardId, Card>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
@ -80,7 +80,7 @@ pub struct Card {
color: u8,
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.
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<CardId, Card>;
type Target = HashMap<CardId, Card>;
fn deref(&self) -> &FnvHashMap<CardId, Card> {
fn deref(&self) -> &HashMap<CardId, Card> {
&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<String, String> {
pub fn extra_properties(&self) -> &HashMap<String, String> {
&self.extra_properties
}
@ -242,8 +242,8 @@ impl Card {
}
}
impl From<FnvHashMap<String, String>> for Card {
fn from(mut map: FnvHashMap<String, String>) -> Card {
impl From<HashMap<String, String>> for Card {
fn from(mut map: HashMap<String, String>) -> Card {
let mut card = Card::new();
if let Some(val) = map.remove("TITLE") {
card.title = val;

View File

@ -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<T: VCardVersion>(
fnv::FnvHashMap<String, ContentLine>,
HashMap<String, ContentLine>,
std::marker::PhantomData<*const T>,
);
impl<V: VCardVersion> VCard<V> {
pub fn new_v4() -> VCard<impl VCardVersion> {
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,

View File

@ -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<std::string::String, Backend>,
map: HashMap<std::string::String, Backend>,
}
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<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 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(
&mut self,
_path: String,
) -> Result<(MailboxHash, FnvHashMap<MailboxHash, Mailbox>)> {
) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
Err(MeliError::new("Unimplemented."))
}
fn delete_mailbox(
&mut self,
_mailbox_hash: MailboxHash,
) -> Result<FnvHashMap<MailboxHash, Mailbox>> {
) -> Result<HashMap<MailboxHash, Mailbox>> {
Err(MeliError::new("Unimplemented."))
}

View File

@ -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<Vec<u8>>;
type Capabilities = HashSet<Vec<u8>>;
#[macro_export]
macro_rules! get_conf_val {
@ -120,11 +120,11 @@ macro_rules! get_conf_val {
#[derive(Debug)]
pub struct UIDStore {
uidvalidity: Arc<Mutex<FnvHashMap<MailboxHash, UID>>>,
hash_index: Arc<Mutex<FnvHashMap<EnvelopeHash, (UID, MailboxHash)>>>,
uid_index: Arc<Mutex<FnvHashMap<UID, EnvelopeHash>>>,
uidvalidity: Arc<Mutex<HashMap<MailboxHash, UID>>>,
hash_index: Arc<Mutex<HashMap<EnvelopeHash, (UID, MailboxHash)>>>,
uid_index: Arc<Mutex<HashMap<UID, EnvelopeHash>>>,
byte_cache: Arc<Mutex<FnvHashMap<UID, EnvelopeCache>>>,
byte_cache: Arc<Mutex<HashMap<UID, EnvelopeCache>>>,
}
#[derive(Debug)]
pub struct ImapType {
@ -137,7 +137,7 @@ pub struct ImapType {
can_create_flags: Arc<Mutex<bool>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, ImapMailbox>>>,
mailboxes: Arc<RwLock<HashMap<MailboxHash, ImapMailbox>>>,
}
#[inline(always)]
@ -407,7 +407,7 @@ impl MailBackend for ImapType {
Ok(handle.thread().id())
}
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> {
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
{
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::<FnvHashSet<MailboxHash>>();
let keys = mailboxes.keys().cloned().collect::<HashSet<MailboxHash>>();
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<MailboxHash, Mailbox>)> {
) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
/* 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<FnvHashMap<MailboxHash, Mailbox>> {
) -> Result<HashMap<MailboxHash, Mailbox>> {
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<Mutex<ImapConnection>>,
) -> Result<FnvHashMap<MailboxHash, ImapMailbox>> {
let mut mailboxes: FnvHashMap<MailboxHash, ImapMailbox> = Default::default();
) -> Result<HashMap<MailboxHash, ImapMailbox>> {
let mut mailboxes: HashMap<MailboxHash, ImapMailbox> = Default::default();
let mut res = String::with_capacity(8 * 1024);
let mut conn = try_lock(&connection)?;
conn.send_command(b"LIST \"\" \"*\"")?;

View File

@ -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();

View File

@ -28,7 +28,7 @@ pub struct ImapWatchKit {
pub is_online: Arc<Mutex<(Instant, Result<()>)>>,
pub main_conn: Arc<Mutex<ImapConnection>>,
pub uid_store: Arc<UIDStore>,
pub mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, ImapMailbox>>>,
pub mailboxes: Arc<RwLock<HashMap<MailboxHash, ImapMailbox>>>,
pub sender: RefreshEventConsumer,
pub work_context: WorkContext,
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::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<EnvelopeHash, EnvelopeCache>,
id_store: FnvHashMap<EnvelopeHash, Id>,
blob_id_store: FnvHashMap<EnvelopeHash, Id>,
byte_cache: HashMap<EnvelopeHash, EnvelopeCache>,
id_store: HashMap<EnvelopeHash, Id>,
blob_id_store: HashMap<EnvelopeHash, Id>,
}
#[derive(Debug)]
@ -189,7 +188,7 @@ pub struct JmapType {
connection: Arc<JmapConnection>,
store: Arc<RwLock<Store>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, JmapMailbox>>>,
mailboxes: Arc<RwLock<HashMap<MailboxHash, JmapMailbox>>>,
}
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<FnvHashMap<MailboxHash, Mailbox>> {
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
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)),

View File

@ -29,7 +29,7 @@ pub struct JmapConnection {
pub online_status: Arc<Mutex<(Instant, Result<()>)>>,
pub server_conf: JmapServerConf,
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 {

View File

@ -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<FnvHashMap<MailboxHash, JmapMailbox>> {
pub fn get_mailboxes(conn: &JmapConnection) -> Result<HashMap<MailboxHash, JmapMailbox>> {
let seq = get_request_no!(conn.request_no);
let res = conn
.client

View File

@ -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<PathBuf> for MaildirPath {
#[derive(Debug, Default)]
pub struct HashIndex {
index: FnvHashMap<EnvelopeHash, MaildirPath>,
index: HashMap<EnvelopeHash, MaildirPath>,
hash: MailboxHash,
}
impl Deref for HashIndex {
type Target = FnvHashMap<EnvelopeHash, MaildirPath>;
fn deref(&self) -> &FnvHashMap<EnvelopeHash, MaildirPath> {
type Target = HashMap<EnvelopeHash, MaildirPath>;
fn deref(&self) -> &HashMap<EnvelopeHash, MaildirPath> {
&self.index
}
}
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
}
}
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
#[derive(Debug)]
pub struct MaildirType {
name: String,
mailboxes: FnvHashMap<MailboxHash, MaildirMailbox>,
mailbox_index: Arc<Mutex<FnvHashMap<EnvelopeHash, MailboxHash>>>,
mailboxes: HashMap<MailboxHash, MaildirMailbox>,
mailbox_index: Arc<Mutex<HashMap<EnvelopeHash, MailboxHash>>>,
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<FnvHashMap<MailboxHash, Mailbox>> {
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
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::<FnvHashSet<EnvelopeHash>>()
map.keys().cloned().collect::<HashSet<EnvelopeHash>>()
};
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::<FnvHashMap<MailboxHash, (Arc<Mutex<usize>>, Arc<Mutex<usize>>)>>();
.collect::<HashMap<MailboxHash, (Arc<Mutex<usize>>, Arc<Mutex<usize>>)>>();
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<MailboxHash, Mailbox>)> {
) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
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<FnvHashMap<MailboxHash, Mailbox>> {
) -> Result<HashMap<MailboxHash, Mailbox>> {
Err(MeliError::new("Unimplemented."))
}
@ -726,9 +726,9 @@ impl MaildirType {
settings: &AccountSettings,
is_subscribed: Box<dyn Fn(&str) -> bool>,
) -> 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>>(
mailboxes: &mut FnvHashMap<MailboxHash, MaildirMailbox>,
mailboxes: &mut HashMap<MailboxHash, MaildirMailbox>,
settings: &AccountSettings,
p: P,
) -> Result<Vec<MailboxHash>> {
@ -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,
},
);

View File

@ -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<Mutex<FnvHashMap<EnvelopeHash, (Offset, Length)>>>,
index: Arc<Mutex<HashMap<EnvelopeHash, (Offset, Length)>>>,
input: &[u8],
file_offset: usize,
) -> IResult<&[u8], Vec<Envelope>> {
@ -387,8 +387,8 @@ pub fn mbox_parse(
#[derive(Debug, Default)]
pub struct MboxType {
path: PathBuf,
index: Arc<Mutex<FnvHashMap<EnvelopeHash, (Offset, Length)>>>,
mailboxes: Arc<Mutex<FnvHashMap<MailboxHash, MboxMailbox>>>,
index: Arc<Mutex<HashMap<EnvelopeHash, (Offset, Length)>>>,
mailboxes: Arc<Mutex<HashMap<MailboxHash, MboxMailbox>>>,
}
impl MailBackend for MboxType {
@ -588,7 +588,7 @@ impl MailBackend for MboxType {
})?;
Ok(handle.thread().id())
}
fn mailboxes(&self) -> Result<FnvHashMap<MailboxHash, Mailbox>> {
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
Ok(self
.mailboxes
.lock()

View File

@ -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<libloading::Library>,
revision_uuid: Arc<RwLock<u64>>,
mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, NotmuchMailbox>>>,
index: Arc<RwLock<FnvHashMap<EnvelopeHash, CString>>>,
mailboxes: Arc<RwLock<HashMap<MailboxHash, NotmuchMailbox>>>,
index: Arc<RwLock<HashMap<EnvelopeHash, CString>>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
path: 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() {
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<FnvHashMap<MailboxHash, Mailbox>> {
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
Ok(self
.mailboxes
.read()
@ -533,7 +534,7 @@ impl MailBackend for NotmuchDb {
#[derive(Debug)]
struct NotmuchOp {
hash: EnvelopeHash,
index: Arc<RwLock<FnvHashMap<EnvelopeHash, CString>>>,
index: Arc<RwLock<HashMap<EnvelopeHash, CString>>>,
tag_index: Arc<RwLock<BTreeMap<u64, String>>>,
database: Arc<DbConnection>,
bytes: Option<String>,

View File

@ -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<EnvelopeHash, Envelope>>,
guard: RwLockReadGuard<'g, HashMap<EnvelopeHash, Envelope>>,
env_hash: EnvelopeHash,
}
@ -43,7 +43,7 @@ impl Deref for EnvelopeRef<'_> {
}
pub struct EnvelopeRefMut<'g> {
guard: RwLockWriteGuard<'g, FnvHashMap<EnvelopeHash, Envelope>>,
guard: RwLockWriteGuard<'g, HashMap<EnvelopeHash, Envelope>>,
env_hash: EnvelopeHash,
}
@ -63,13 +63,13 @@ impl DerefMut for EnvelopeRefMut<'_> {
#[derive(Debug, Clone, Deserialize, Default, Serialize)]
pub struct Collection {
pub envelopes: Arc<RwLock<FnvHashMap<EnvelopeHash, Envelope>>>,
message_ids: FnvHashMap<Vec<u8>, EnvelopeHash>,
pub envelopes: Arc<RwLock<HashMap<EnvelopeHash, Envelope>>>,
message_ids: HashMap<Vec<u8>, EnvelopeHash>,
date_index: BTreeMap<UnixTimestamp, EnvelopeHash>,
subject_index: Option<BTreeMap<String, EnvelopeHash>>,
pub threads: FnvHashMap<MailboxHash, Threads>,
pub threads: HashMap<MailboxHash, Threads>,
sent_mailbox: Option<MailboxHash>,
pub mailboxes: FnvHashMap<MailboxHash, FnvHashSet<EnvelopeHash>>,
pub mailboxes: HashMap<MailboxHash, HashSet<EnvelopeHash>>,
}
impl Drop for Collection {
@ -93,17 +93,17 @@ impl Drop for 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 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<EnvelopeHash, Envelope>,
mut new_envelopes: HashMap<EnvelopeHash, Envelope>,
mailbox_hash: MailboxHash,
sent_mailbox: Option<MailboxHash>,
) -> Option<SmallVec<[MailboxHash; 8]>> {
@ -407,14 +407,14 @@ impl Collection {
}
impl Index<&MailboxHash> for Collection {
type Output = FnvHashSet<EnvelopeHash>;
fn index(&self, index: &MailboxHash) -> &FnvHashSet<EnvelopeHash> {
type Output = HashSet<EnvelopeHash>;
fn index(&self, index: &MailboxHash) -> &HashSet<EnvelopeHash> {
&self.mailboxes[index]
}
}
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()
}
}

View File

@ -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<MessageID>,
pub references: Option<References>,
other_headers: FnvHashMap<String, String>,
other_headers: HashMap<String, String>,
timestamp: UnixTimestamp,
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
}
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
}

View File

@ -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<String, String>,
pub headers: HashMap<String, String>,
pub header_order: Vec<String>,
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<String, String> {
pub fn headers_mut(&mut self) -> &mut HashMap<String, String> {
&mut self.headers
}
pub fn headers(&self) -> &FnvHashMap<String, String> {
pub fn headers(&self) -> &HashMap<String, String> {
&self.headers
}

View File

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

View File

@ -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<RwLock<FnvHashMap<EnvelopeHash, Envelope>>>;
type Envelopes = Arc<RwLock<HashMap<EnvelopeHash, Envelope>>>;
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<ThreadNodeHash, ThreadNode>,
pub thread_nodes: HashMap<ThreadNodeHash, ThreadNode>,
root_set: RefCell<Vec<ThreadNodeHash>>,
tree_index: RefCell<Vec<ThreadNodeHash>>,
pub groups: FnvHashMap<ThreadHash, ThreadGroup>,
pub groups: HashMap<ThreadHash, ThreadGroup>,
message_ids: FnvHashMap<Vec<u8>, ThreadNodeHash>,
pub message_ids_set: FnvHashSet<Vec<u8>>,
pub missing_message_ids: FnvHashSet<Vec<u8>>,
pub hash_set: FnvHashSet<EnvelopeHash>,
message_ids: HashMap<Vec<u8>, ThreadNodeHash>,
pub message_ids_set: HashSet<Vec<u8>>,
pub missing_message_ids: HashSet<Vec<u8>>,
pub hash_set: HashSet<EnvelopeHash>,
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<ThreadNodeHash, ThreadNode> =
FnvHashMap::with_capacity_and_hasher(
(length as f64 * 1.2) as usize,
Default::default(),
);
let thread_nodes: HashMap<ThreadNodeHash, ThreadNode> =
HashMap::with_capacity_and_hasher((length as f64 * 1.2) as usize, Default::default());
/* A hash table of Message IDs */
let message_ids: FnvHashMap<Vec<u8>, ThreadNodeHash> =
FnvHashMap::with_capacity_and_hasher(length, Default::default());
let message_ids: HashMap<Vec<u8>, 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<Vec<u8>> =
FnvHashSet::with_capacity_and_hasher(length, Default::default());
let missing_message_ids: HashSet<Vec<u8>> =
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<Vec<u8>> =
FnvHashSet::with_capacity_and_hasher(length, Default::default());
let hash_set: FnvHashSet<EnvelopeHash> =
FnvHashSet::with_capacity_and_hasher(length, Default::default());
let message_ids_set: HashSet<Vec<u8>> =
HashSet::with_capacity_and_hasher(length, Default::default());
let hash_set: HashSet<EnvelopeHash> =
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<EnvelopeHash> =
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::<FnvHashMap<ThreadNodeHash, Vec<u8>>>(),
.collect::<HashMap<ThreadNodeHash, Vec<u8>>>(),
&envelopes,
);
*/
@ -1168,7 +1165,7 @@ impl Threads {
thread.message().unwrap()
}
pub fn thread_nodes(&self) -> &FnvHashMap<ThreadNodeHash, ThreadNode> {
pub fn thread_nodes(&self) -> &HashMap<ThreadNodeHash, ThreadNode> {
&self.thread_nodes
}
@ -1206,13 +1203,13 @@ impl Index<&ThreadNodeHash> for Threads {
/*
fn print_threadnodes(
node_hash: ThreadNodeHash,
nodes: &FnvHashMap<ThreadNodeHash, ThreadNode>,
nodes: &HashMap<ThreadNodeHash, ThreadNode>,
envelopes: &Envelopes,
) {
fn help(
level: usize,
node_hash: ThreadNodeHash,
nodes: &FnvHashMap<ThreadNodeHash, ThreadNode>,
nodes: &HashMap<ThreadNodeHash, ThreadNode>,
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<ThreadNodeHash, ThreadNode>,
ids: &FnvHashMap<ThreadNodeHash, Vec<u8>>,
nodes: &HashMap<ThreadNodeHash, ThreadNode>,
ids: &HashMap<ThreadNodeHash, Vec<u8>>,
envelopes: &Envelopes,
) {
let envelopes = envelopes.read().unwrap();

View File

@ -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<ThreadNodeHash, ThreadNode>,
pub(super) thread_nodes: &'a HashMap<ThreadNodeHash, ThreadNode>,
}
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<ThreadNodeHash, ThreadNode>,
pub(super) thread_nodes: &'a HashMap<ThreadNodeHash, ThreadNode>,
}
impl<'a> Iterator for ThreadGroupIterator<'a> {

View File

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

View File

@ -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

View File

@ -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<String, String> = fields
let fields: HashMap<String, String> = fields
.into_iter()
.map(|(s, v)| {
(

View File

@ -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<MailboxHash, Mailbox> = context.accounts[a.index]
let mailboxes: HashMap<MailboxHash, Mailbox> = context.accounts[a.index]
.mailbox_entries
.iter()
.map(|(&hash, entry)| (hash, entry.ref_mailbox.clone()))

View File

@ -54,15 +54,15 @@ pub struct CompactListing {
length: usize,
sort: (SortField, SortOrder),
subsort: (SortField, SortOrder),
all_threads: fnv::FnvHashSet<ThreadHash>,
order: FnvHashMap<ThreadHash, usize>,
all_threads: HashSet<ThreadHash>,
order: HashMap<ThreadHash, usize>,
/// Cache current view.
data_columns: DataColumns,
filter_term: String,
filtered_selection: Vec<ThreadHash>,
filtered_order: FnvHashMap<ThreadHash, usize>,
selection: FnvHashMap<ThreadHash, bool>,
filtered_order: HashMap<ThreadHash, usize>,
selection: HashMap<ThreadHash, bool>,
/// 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,

View File

@ -33,15 +33,15 @@ pub struct ConversationsListing {
length: usize,
sort: (SortField, SortOrder),
subsort: (SortField, SortOrder),
all_threads: fnv::FnvHashSet<ThreadHash>,
order: FnvHashMap<ThreadHash, usize>,
all_threads: HashSet<ThreadHash>,
order: HashMap<ThreadHash, usize>,
/// Cache current view.
content: CellBuffer,
filter_term: String,
filtered_selection: Vec<ThreadHash>,
filtered_order: FnvHashMap<ThreadHash, usize>,
selection: FnvHashMap<ThreadHash, bool>,
filtered_order: HashMap<ThreadHash, usize>,
selection: HashMap<ThreadHash, bool>,
/// 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,

View File

@ -53,16 +53,16 @@ pub struct PlainListing {
length: usize,
sort: (SortField, SortOrder),
subsort: (SortField, SortOrder),
all_envelopes: fnv::FnvHashSet<EnvelopeHash>,
order: FnvHashMap<EnvelopeHash, usize>,
all_envelopes: HashSet<EnvelopeHash>,
order: HashMap<EnvelopeHash, usize>,
/// Cache current view.
data_columns: DataColumns,
filter_term: String,
filtered_selection: Vec<EnvelopeHash>,
filtered_order: FnvHashMap<EnvelopeHash, usize>,
selection: FnvHashMap<EnvelopeHash, bool>,
thread_node_hashes: FnvHashMap<EnvelopeHash, ThreadNodeHash>,
filtered_order: HashMap<EnvelopeHash, usize>,
selection: HashMap<EnvelopeHash, bool>,
thread_node_hashes: HashMap<EnvelopeHash, ThreadNodeHash>,
local_collection: Vec<EnvelopeHash>,
/// 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(),

View File

@ -39,7 +39,7 @@ pub struct ThreadListing {
color_cache: ColorCache,
row_updates: SmallVec<[ThreadHash; 8]>,
order: FnvHashMap<EnvelopeHash, usize>,
order: HashMap<EnvelopeHash, usize>,
/// 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<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() */
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,

View File

@ -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<AutoCompleteEntry> = self
.cmd_history
.iter()

View File

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

View File

@ -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<MailboxHash, MailboxEntry>,
pub(crate) mailbox_entries: HashMap<MailboxHash, MailboxEntry>,
pub(crate) mailboxes_order: Vec<MailboxHash>,
tree: Vec<MailboxNode>,
sent_mailbox: Option<MailboxHash>,
@ -251,7 +251,7 @@ impl Account {
}
fn init(&mut self) {
let mut ref_mailboxes: FnvHashMap<MailboxHash, Mailbox> =
let mut ref_mailboxes: HashMap<MailboxHash, Mailbox> =
match self.backend.read().unwrap().mailboxes() {
Ok(f) => f,
Err(err) => {
@ -259,8 +259,8 @@ impl Account {
return;
}
};
let mut mailbox_entries: FnvHashMap<MailboxHash, MailboxEntry> =
FnvHashMap::with_capacity_and_hasher(ref_mailboxes.len(), Default::default());
let mut mailbox_entries: HashMap<MailboxHash, MailboxEntry> =
HashMap::with_capacity_and_hasher(ref_mailboxes.len(), Default::default());
let mut mailboxes_order: Vec<MailboxHash> = 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::<FnvHashMap<EnvelopeHash, Envelope>>();
.collect::<HashMap<EnvelopeHash, Envelope>>();
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<MailboxNode>,
mailbox_entries: &FnvHashMap<MailboxHash, MailboxEntry>,
mailbox_entries: &HashMap<MailboxHash, MailboxEntry>,
mailboxes_order: &mut Vec<MailboxHash>,
) {
tree.clear();
@ -1215,7 +1215,7 @@ fn build_mailboxes_order(
if f.ref_mailbox.parent().is_none() {
fn rec(
h: MailboxHash,
mailbox_entries: &FnvHashMap<MailboxHash, MailboxEntry>,
mailbox_entries: &HashMap<MailboxHash, MailboxEntry>,
depth: usize,
) -> MailboxNode {
let mut node = MailboxNode {

View File

@ -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()

View File

@ -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)?;

View File

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

View File

@ -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<FnvHashMap<MailboxHash, Mailbox>> {
let mut ret: FnvHashMap<MailboxHash, Mailbox> = Default::default();
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>> {
let mut ret: HashMap<MailboxHash, Mailbox> = 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<MailboxHash, Mailbox>)> {
) -> Result<(MailboxHash, HashMap<MailboxHash, Mailbox>)> {
Err(MeliError::new("Unimplemented."))
}
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 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<Account>,
pub mailbox_hashes: FnvHashMap<MailboxHash, usize>,
pub mailbox_hashes: HashMap<MailboxHash, usize>,
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,

View File

@ -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<bool>,
/// 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)
pub static_threads: Arc<Mutex<FnvHashMap<thread::ThreadId, Worker>>>,
pub static_threads: Arc<Mutex<HashMap<thread::ThreadId, Worker>>>,
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<Mutex<FnvHashMap<thread::ThreadId, Worker>>> =
Arc::new(Mutex::new(FnvHashMap::default()));
let threads_lock: Arc<Mutex<HashMap<thread::ThreadId, Worker>>> =
Arc::new(Mutex::new(HashMap::default()));
let static_threads_lock: Arc<Mutex<FnvHashMap<thread::ThreadId, Worker>>> =
Arc::new(Mutex::new(FnvHashMap::default()));
let static_threads_lock: Arc<Mutex<HashMap<thread::ThreadId, Worker>>> =
Arc::new(Mutex::new(HashMap::default()));
let mut threads = threads_lock.lock().unwrap();
/* spawn worker threads */