summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-05-10 21:14:49 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-05-10 21:18:56 +0300
commiteb701695f71d6e62f5f11b85d3b367494a23c48b (patch)
tree5b29ea6b93694e63e7f5e09430e1b2240d0e1bfb
parentb5b9982d9eb8c17b72fcd5599b4999f760d6f570 (diff)
Remove fnv crate
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml1
-rw-r--r--melib/Cargo.toml1
-rw-r--r--melib/src/addressbook.rs20
-rw-r--r--melib/src/addressbook/vcard.rs8
-rw-r--r--melib/src/backends.rs12
-rw-r--r--melib/src/backends/imap.rs29
-rw-r--r--melib/src/backends/imap/connection.rs8
-rw-r--r--melib/src/backends/imap/watch.rs2
-rw-r--r--melib/src/backends/jmap.rs15
-rw-r--r--melib/src/backends/jmap/connection.rs2
-rw-r--r--melib/src/backends/jmap/protocol.rs3
-rw-r--r--melib/src/backends/maildir/backend.rs40
-rw-r--r--melib/src/backends/mbox.rs10
-rw-r--r--melib/src/backends/notmuch.rs17
-rw-r--r--melib/src/collection.rs30
-rw-r--r--melib/src/email.rs8
-rw-r--r--melib/src/email/compose.rs10
-rw-r--r--melib/src/lib.rs1
-rw-r--r--melib/src/thread.rs53
-rw-r--r--melib/src/thread/iterators.rs6
-rw-r--r--src/bin.rs1
-rw-r--r--src/components.rs6
-rw-r--r--src/components/contacts.rs4
-rw-r--r--src/components/mail/listing.rs3
-rw-r--r--src/components/mail/listing/compact.rs16
-rw-r--r--src/components/mail/listing/conversations.rs16
-rw-r--r--src/components/mail/listing/plain.rs20
-rw-r--r--src/components/mail/listing/thread.rs6
-rw-r--r--src/components/utilities.rs7
-rw-r--r--src/components/utilities/widgets.rs10
-rw-r--r--src/conf/accounts.rs16
-rw-r--r--src/conf/shortcuts.rs4
-rw-r--r--src/mailcap.rs4
-rw-r--r--src/managesieve.rs1
-rw-r--r--src/plugins/backend.rs8
-rw-r--r--src/state.rs6
-rw-r--r--src/workers.rs14
38 files changed, 203 insertions, 217 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b0d25681..25026cbf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -685,7 +685,6 @@ dependencies = [
"bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"linkify 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"melib 0.5.0",
@@ -720,7 +719,6 @@ dependencies = [
"crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
- "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 01ee2d4f..92ca8ca3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,6 @@ serde = "1.0.71"
serde_derive = "1.0.71"
serde_json = "1.0"
toml = "0.5.3"
-fnv = "1.0.3" # >:c
linkify = "0.3.1" # >:c
xdg-utils = "0.3.0"
nom = "3.2.0"
diff --git a/melib/Cargo.toml b/melib/Cargo.toml
index e7a46c7c..e400e25d 100644
--- a/melib/Cargo.toml
+++ b/melib/Cargo.toml
@@ -22,7 +22,6 @@ bitflags = "1.0"
crossbeam = "0.7.2"
data-encoding = "2.1.1"
encoding = "0.2.33"
-fnv = "1.0.3"
memmap = { version = "0.5.2", optional = true }
nom = "3.2.0"
notify = { version = "4.0.1", optional = true }
diff --git a/melib/src/addressbook.rs b/melib/src/addressbook.rs
index 3b592090..3ce2fefe 100644
--- a/melib/src/addressbook.rs
+++ b/melib/src/addressbook.rs
@@ -23,7 +23,7 @@
pub mod vcard;
use crate::datetime::{self, UnixTimestamp};
-use fnv::FnvHashMap;
+use std::collections::HashMap;
use uuid::Uuid;
use std::ops::Deref;
@@ -61,7 +61,7 @@ pub struct AddressBook {
display_name: String,
created: UnixTimestamp,
last_edited: UnixTimestamp,
- pub cards: FnvHashMap<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;
diff --git a/melib/src/addressbook/vcard.rs b/melib/src/addressbook/vcard.rs
index ac06215c..7999dbfe 100644
--- a/melib/src/addressbook/vcard.rs
+++ b/melib/src/addressbook/vcard.rs
@@ -23,7 +23,7 @@
use super::*;
use crate::error::{MeliError, Result};
use crate::parsec::{match_literal_anycase, one_or_more, peek, prefix, take_until, Parser};
-use fnv::FnvHashMap;
+use std::collections::HashMap;
use std::convert::TryInto;
/* Supported vcard versions */
@@ -50,14 +50,14 @@ static FOOTER: &'static str = "END:VCARD\r\n";
#[derive(Debug)]
pub struct VCard<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,
diff --git a/melib/src/backends.rs b/melib/src/backends.rs
index 71ac5186..f79e897f 100644
--- a/melib/src/backends.rs
+++ b/melib/src/backends.rs
@@ -64,8 +64,8 @@ use std::fmt::Debug;
use std::ops::Deref;
use std::sync::{Arc, RwLock};
-use fnv::FnvHashMap;
use std;
+use std::collections::HashMap;
#[macro_export]
macro_rules! get_path_hash {
@@ -88,7 +88,7 @@ pub type BackendCreator = Box<
/// A hashmap containing all available mail backends.
/// An abstraction over any available backends.
pub struct Backends {
- map: FnvHashMap<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."))
}
diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs
index eedb7fa0..e9b0dea3 100644
--- a/melib/src/backends/imap.rs
+++ b/melib/src/backends/imap.rs
@@ -43,8 +43,8 @@ use crate::backends::{BackendMailbox, MailBackend, Mailbox, RefreshEventConsumer
use crate::conf::AccountSettings;
use crate::email::*;
use crate::error::{MeliError, Result};
-use fnv::{FnvHashMap, FnvHashSet};
use std::collections::{hash_map::DefaultHasher, BTreeMap};
+use std::collections::{HashMap, HashSet};
use std::hash::Hasher;
use std::str::FromStr;
use std::sync::{Arc, Mutex, RwLock};
@@ -87,7 +87,7 @@ impl std::ops::Deref for IsSubscribedFn {
&self.0
}
}
-type Capabilities = FnvHashSet<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 \"\" \"*\"")?;
diff --git a/melib/src/backends/imap/connection.rs b/melib/src/backends/imap/connection.rs
index 31246b50..570abaf1 100644
--- a/melib/src/backends/imap/connection.rs
+++ b/melib/src/backends/imap/connection.rs
@@ -25,8 +25,8 @@ use crate::error::*;
use std::io::Read;
use std::io::Write;
extern crate native_tls;
-use fnv::FnvHashSet;
use native_tls::TlsConnector;
+use std::collections::HashSet;
use std::iter::FromIterator;
use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
@@ -241,9 +241,7 @@ impl ImapStream {
capabilities = protocol_parser::capabilities(l.as_bytes())
.to_full_result()
.map(|capabilities| {
- FnvHashSet::from_iter(
- capabilities.into_iter().map(|s: &[u8]| s.to_vec()),
- )
+ HashSet::from_iter(capabilities.into_iter().map(|s: &[u8]| s.to_vec()))
})
.ok();
}
@@ -270,7 +268,7 @@ impl ImapStream {
ret.send_command(b"CAPABILITY")?;
ret.read_response(&mut res).unwrap();
let capabilities = protocol_parser::capabilities(res.as_bytes()).to_full_result()?;
- let capabilities = FnvHashSet::from_iter(capabilities.into_iter().map(|s| s.to_vec()));
+ let capabilities = HashSet::from_iter(capabilities.into_iter().map(|s| s.to_vec()));
Ok((capabilities, ret))
} else {
let capabilities = capabilities.unwrap();
diff --git a/melib/src/backends/imap/watch.rs b/melib/src/backends/imap/watch.rs
index 685fc17a..050b4fb8 100644
--- a/melib/src/backends/imap/watch.rs
+++ b/melib/src/backends/imap/watch.rs
@@ -28,7 +28,7 @@ pub struct ImapWatchKit {
pub is_online: Arc<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>>>,
diff --git a/melib/src/backends/jmap.rs b/melib/src/backends/jmap.rs
index 32d6df9d..774b2d0c 100644
--- a/melib/src/backends/jmap.rs
+++ b/melib/src/backends/jmap.rs
@@ -26,9 +26,8 @@ use crate::backends::{BackendMailbox, MailBackend, Mailbox, RefreshEventConsumer
use crate::conf::AccountSettings;
use crate::email::*;
use crate::error::{MeliError, Result};
-use fnv::FnvHashMap;
use reqwest::blocking::Client;
-use std::collections::BTreeMap;
+use std::collections::{BTreeMap, HashMap};
use std::str::FromStr;
use std::sync::{Arc, Mutex, RwLock};
use std::time::Instant;
@@ -175,9 +174,9 @@ macro_rules! get_conf_val {
#[derive(Debug, Default)]
pub struct Store {
- byte_cache: FnvHashMap<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)),
diff --git a/melib/src/backends/jmap/connection.rs b/melib/src/backends/jmap/connection.rs
index ecd48905..110d10de 100644
--- a/melib/src/backends/jmap/connection.rs
+++ b/melib/src/backends/jmap/connection.rs
@@ -29,7 +29,7 @@ pub struct JmapConnection {
pub online_status: Arc<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 {
diff --git a/melib/src/backends/jmap/protocol.rs b/melib/src/backends/jmap/protocol.rs
index 32ba2ed2..1693723e 100644
--- a/melib/src/backends/jmap/protocol.rs
+++ b/melib/src/backends/jmap/protocol.rs
@@ -25,6 +25,7 @@ use serde::Serialize;
use serde_json::{json, Value};
use smallvec::SmallVec;
use std::collections::hash_map::DefaultHasher;
+use std::collections::HashMap;
use std::convert::TryFrom;
use std::hash::{Hash, Hasher};
@@ -94,7 +95,7 @@ impl Request {
}
}
-pub fn get_mailboxes(conn: &JmapConnection) -> Result<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
diff --git a/melib/src/backends/maildir/backend.rs b/melib/src/backends/maildir/backend.rs
index 210669bf..894a7847 100644
--- a/melib/src/backends/maildir/backend.rs
+++ b/melib/src/backends/maildir/backend.rs
@@ -34,10 +34,10 @@ extern crate notify;
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::time::Duration;
-use fnv::{FnvHashMap, FnvHashSet, FnvHasher};
+use std::collections::{HashMap, HashSet, hash_map::DefaultHasher};
use std::ffi::OsStr;
use std::fs;
-use std::hash::{Hash, Hasher};
+use std::hash::{Hasher, Hash};
use std::io::{self, Read, Write};
use std::ops::{Deref, DerefMut};
use std::os::unix::fs::PermissionsExt;
@@ -87,31 +87,31 @@ impl From<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,
},
);
diff --git a/melib/src/backends/mbox.rs b/melib/src/backends/mbox.rs
index c652983b..599b5a9f 100644
--- a/melib/src/backends/mbox.rs
+++ b/melib/src/backends/mbox.rs
@@ -36,12 +36,12 @@ use crate::email::*;
use crate::error::{MeliError, Result};
use crate::get_path_hash;
use crate::shellexpand::ShellExpandTrait;
-use fnv::FnvHashMap;
use libc;
use memmap::{Mmap, Protection};
use nom::{IResult, Needed};
extern crate notify;
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
+use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
@@ -269,7 +269,7 @@ impl BackendOp for MboxOp {
}
pub fn mbox_parse(
- index: Arc<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()
diff --git a/melib/src/backends/notmuch.rs b/melib/src/backends/notmuch.rs
index 27e43c4f..0d7513f3 100644
--- a/melib/src/backends/notmuch.rs
+++ b/melib/src/backends/notmuch.rs
@@ -29,10 +29,11 @@ use crate::conf::AccountSettings;
use crate::email::{Envelope, EnvelopeHash, Flag};
use crate::error::{MeliError, Result};
use crate::shellexpand::ShellExpandTrait;
-use fnv::FnvHashMap;
use smallvec::SmallVec;
-use std::collections::hash_map::DefaultHasher;
-use std::collections::BTreeMap;
+use std::collections::{
+ hash_map::{DefaultHasher, HashMap},
+ BTreeMap,
+};
use std::error::Error;
use std::ffi::{CStr, CString, OsStr};
use std::hash::{Hash, Hasher};
@@ -104,8 +105,8 @@ impl Drop for DbConnection {
pub struct NotmuchDb {
lib: Arc<libloading::Library>,
revision_uuid: Arc<RwLock<u64>>,
- mailboxes: Arc<RwLock<FnvHashMap<MailboxHash, NotmuchMailbox>>>,
- index: Arc<RwLock<FnvHashMap<Envelo