mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-21 05:38:20 -05:00
⚡ perf: replace Vec<T>
with Box<T>
& initialize vectors with capacity by default (#603)
This commit is contained in:
parent
4bb6c5e90b
commit
39af9096ef
6
src/cache/redis_cacher.rs
vendored
6
src/cache/redis_cacher.rs
vendored
@ -16,7 +16,7 @@ const REDIS_PIPELINE_SIZE: usize = 3;
|
||||
/// connect to.
|
||||
pub struct RedisCache {
|
||||
/// It stores a pool of connections ready to be used.
|
||||
connection_pool: Vec<ConnectionManager>,
|
||||
connection_pool: Box<[ConnectionManager]>,
|
||||
/// It stores the size of the connection pool (in other words the number of
|
||||
/// connections that should be stored in the pool).
|
||||
pool_size: u8,
|
||||
@ -58,13 +58,13 @@ impl RedisCache {
|
||||
}));
|
||||
}
|
||||
|
||||
let mut outputs = Vec::new();
|
||||
let mut outputs = Vec::with_capacity(tasks.len());
|
||||
for task in tasks {
|
||||
outputs.push(task.await??);
|
||||
}
|
||||
|
||||
let redis_cache = RedisCache {
|
||||
connection_pool: outputs,
|
||||
connection_pool: outputs.into_boxed_slice(),
|
||||
pool_size,
|
||||
current_connection: Default::default(),
|
||||
cache_ttl,
|
||||
|
Loading…
Reference in New Issue
Block a user