mirror of
https://github.com/sadoyan/aralez.git
synced 2026-04-29 22:38:36 +08:00
Compare dashmaps
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::utils::tools::*;
|
||||
use std::collections::HashSet;
|
||||
use tokio::sync::RwLockReadGuard;
|
||||
|
||||
#[allow(dead_code)]
|
||||
// #[allow(dead_code)]
|
||||
pub fn dm(map1: &RwLockReadGuard<UpstreamMap>, map2: &UpstreamMap) -> bool {
|
||||
if map1.len() != map2.len() {
|
||||
return false; // Different number of keys
|
||||
@@ -22,7 +22,7 @@ pub fn dm(map1: &RwLockReadGuard<UpstreamMap>, map2: &UpstreamMap) -> bool {
|
||||
}
|
||||
true
|
||||
}
|
||||
// #[allow(dead_code)]
|
||||
#[allow(dead_code)]
|
||||
pub fn dam(map1: &UpstresmDashMap, map2: &UpstresmDashMap) -> bool {
|
||||
// Step 1: Check if both maps have the same keys
|
||||
let keys1: HashSet<_> = map1.iter().map(|entry| entry.key().clone()).collect();
|
||||
|
||||
@@ -153,7 +153,6 @@ pub fn build_upstreams(d: &str, kind: &str) -> UpstreamMap {
|
||||
|
||||
pub fn build_upstreams2(d: &str, kind: &str) -> UpstresmDashMap {
|
||||
let upstreams: UpstresmDashMap = DashMap::new();
|
||||
let hopar: UpstresmDashMap = DashMap::new();
|
||||
let mut contents = d.to_string();
|
||||
match kind {
|
||||
"filepath" => {
|
||||
@@ -210,12 +209,6 @@ pub fn build_upstreams2(d: &str, kind: &str) -> UpstresmDashMap {
|
||||
.or_insert_with(|| (Vec::new(), AtomicUsize::new(0)))
|
||||
.0
|
||||
.push((ip.to_string(), port, ssl, proto.to_string()));
|
||||
let entry = hopar.entry(hostname.to_string()).or_insert_with(DashMap::new);
|
||||
entry
|
||||
.entry(path.to_string())
|
||||
.or_insert_with(|| (Vec::new(), AtomicUsize::new(0)))
|
||||
.0
|
||||
.push((ip.to_string(), port, ssl, proto.to_string()));
|
||||
}
|
||||
// println!("\n\nResult ===> {} <===\n\n", dam(&hopar, &upstreams));
|
||||
// println!("{:?}", hopar);
|
||||
|
||||
Reference in New Issue
Block a user