Unverified Commit 7bb628af authored by Niklas Adolfsson's avatar Niklas Adolfsson Committed by GitHub
Browse files

clients: use `FxHashMap` instead `FnvHashMap` (#592)

* deps: use `FxHashMap` instead `fnv`

* fmt
parent 3f1c7fcf
......@@ -11,7 +11,7 @@ documentation = "https://docs.rs/jsonrpsee-http-client"
[dependencies]
async-trait = "0.1"
fnv = "1"
rustc-hash = "1"
hyper = { version = "0.14.10", features = ["client", "http1", "http2", "tcp"] }
hyper-rustls = { version = "0.23", optional = true }
jsonrpsee-types = { path = "../types", version = "0.6.0" }
......
......@@ -31,7 +31,7 @@ use crate::types::{
CertificateStore, Error, RequestIdManager, Subscription, TEN_MB_SIZE_BYTES,
};
use async_trait::async_trait;
use fnv::FnvHashMap;
use rustc_hash::FxHashMap;
use serde::de::DeserializeOwned;
use std::{sync::Arc, time::Duration};
......@@ -158,7 +158,7 @@ impl Client for HttpClient {
let mut batch_request = Vec::with_capacity(batch.len());
// NOTE(niklasad1): `ID` is not necessarily monotonically increasing.
let mut ordered_requests = Vec::with_capacity(batch.len());
let mut request_set = FnvHashMap::with_capacity_and_hasher(batch.len(), Default::default());
let mut request_set = FxHashMap::with_capacity_and_hasher(batch.len(), Default::default());
let ids = self.id_manager.next_request_ids(batch.len())?;
for (pos, (method, params)) in batch.into_iter().enumerate() {
......
......@@ -11,7 +11,7 @@ documentation = "https://docs.rs/jsonrpsee-ws-client"
[dependencies]
async-trait = "0.1"
fnv = "1"
rustc-hash = "1"
futures = { version = "0.3.14", default-features = false, features = ["std"] }
http = "0.2"
jsonrpsee-types = { path = "../types", version = "0.6.0" }
......
......@@ -33,8 +33,8 @@
//! - SubscriptionId: unique ID generated by server
use crate::types::{v2::SubscriptionId, Error, JsonValue};
use fnv::FnvHashMap;
use futures::channel::{mpsc, oneshot};
use rustc_hash::FxHashMap;
use std::collections::hash_map::{Entry, HashMap};
#[derive(Debug)]
......@@ -68,7 +68,7 @@ type RequestId = u64;
/// Batch state.
pub struct BatchState {
/// Order that the request was performed in.
pub order: FnvHashMap<RequestId, usize>,
pub order: FxHashMap<RequestId, usize>,
/// Oneshot send back.
pub send_back: PendingBatchOneshot,
}
......@@ -79,12 +79,12 @@ pub struct RequestManager {
/// List of requests that are waiting for a response from the server.
// NOTE: FnvHashMap is used here because RequestId is not under the caller's control and is known to be a short
// key.
requests: FnvHashMap<RequestId, Kind>,
requests: FxHashMap<RequestId, Kind>,
/// Reverse lookup, to find a request ID in constant time by `subscription ID` instead of looking through all
/// requests.
subscriptions: HashMap<SubscriptionId, RequestId>,
/// Pending batch requests
batches: FnvHashMap<Vec<RequestId>, BatchState>,
batches: FxHashMap<Vec<RequestId>, BatchState>,
/// Registered Methods for incoming notifications
notification_handlers: HashMap<String, SubscriptionSink>,
}
......@@ -119,7 +119,7 @@ impl RequestManager {
mut batch: Vec<RequestId>,
send_back: PendingBatchOneshot,
) -> Result<(), PendingBatchOneshot> {
let mut order = FnvHashMap::with_capacity_and_hasher(batch.len(), Default::default());
let mut order = FxHashMap::with_capacity_and_hasher(batch.len(), Default::default());
for (idx, batch_id) in batch.iter().enumerate() {
order.insert(*batch_id, idx);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment