Migrated to AHashMap.

This commit is contained in:
Mauro D
2022-08-02 16:08:08 +00:00
parent 7300ac7b84
commit 45f0aa3d81
24 changed files with 125 additions and 181 deletions

View File

@@ -1,8 +1,6 @@
use std::collections::HashMap;
use crate::{core::get::GetObject, Get, Set};
use super::{Principal, Type, ACL, DKIM};
use crate::{core::get::GetObject, Get, Set};
use ahash::AHashMap;
impl Principal<Get> {
pub fn id(&self) -> Option<&str> {
@@ -57,7 +55,7 @@ impl Principal<Get> {
self.dkim.as_ref()
}
pub fn acl(&self) -> Option<&HashMap<String, Vec<ACL>>> {
pub fn acl(&self) -> Option<&AHashMap<String, Vec<ACL>>> {
self.acl.as_ref()
}
}

View File

@@ -4,9 +4,9 @@ pub mod query;
pub mod set;
use crate::core::set::{list_not_set, map_not_set, string_not_set};
use std::{collections::HashMap, fmt::Display};
use ahash::AHashMap;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
use crate::{
core::{changes::ChangesObject, Object},
@@ -49,7 +49,7 @@ pub struct Principal<State = Get> {
#[serde(skip_serializing_if = "list_not_set")]
members: Option<Vec<String>>,
#[serde(skip_serializing_if = "map_not_set")]
acl: Option<HashMap<String, Vec<ACL>>>,
acl: Option<AHashMap<String, Vec<ACL>>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Copy)]

View File

@@ -1,8 +1,6 @@
use std::collections::HashMap;
use crate::{core::set::SetObject, Get, Set};
use super::{Principal, Type, ACL, DKIM};
use crate::{core::set::SetObject, Get, Set};
use ahash::AHashMap;
impl Principal<Set> {
pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
@@ -50,7 +48,7 @@ impl Principal<Set> {
self
}
pub fn acl(&mut self, acl: Option<HashMap<String, Vec<ACL>>>) -> &mut Self {
pub fn acl(&mut self, acl: Option<AHashMap<String, Vec<ACL>>>) -> &mut Self {
self.acl = acl;
self
}
@@ -103,7 +101,7 @@ impl SetObject for Principal<Set> {
quota: None,
picture: "".to_string().into(),
members: Vec::with_capacity(0).into(),
acl: HashMap::with_capacity(0).into(),
acl: AHashMap::with_capacity(0).into(),
}
}