Skip to content

Commit 0a5746d

Browse files
committed
Got bitten by a macro bug. v3.0.5
1 parent ae970f5 commit 0a5746d

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dashmap"
3-
version = "3.0.4"
3+
version = "3.0.5"
44
authors = ["Acrimon <[email protected]>"]
55
edition = "2018"
66
license = "MIT"

src/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::mapref::multiple::{RefMulti, RefMutMulti};
22
use super::util;
33
use crate::t::Map;
4-
use crate::HashMap;
54
use crate::util::SharedValue;
5+
use crate::HashMap;
66
use parking_lot::{RwLockReadGuard, RwLockWriteGuard};
77
use std::collections::hash_map;
88
use std::hash::Hash;

src/lib.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod util;
88
#[cfg(feature = "serde")]
99
mod serde;
1010

11+
use cfg_if::cfg_if;
1112
use fxhash::FxBuildHasher;
1213
use iter::{Iter, IterMut};
1314
use mapref::entry::{Entry, OccupiedEntry, VacantEntry};
@@ -19,7 +20,6 @@ use std::iter::FromIterator;
1920
use std::ops::{BitAnd, BitOr, Shl, Shr, Sub};
2021
use t::Map;
2122
use util::SharedValue;
22-
use cfg_if::cfg_if;
2323

2424
type HashMap<K, V> = std::collections::HashMap<K, SharedValue<V>, FxBuildHasher>;
2525

@@ -121,6 +121,12 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
121121
pub fn shards(&self) -> &[RwLock<HashMap<K, V>>] {
122122
&self.shards
123123
}
124+
} else {
125+
#[allow(dead_code)]
126+
#[inline]
127+
fn shards(&self) -> &[RwLock<HashMap<K, V>>] {
128+
&self.shards
129+
}
124130
}
125131
}
126132

@@ -146,7 +152,7 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
146152
{
147153
let hash = fxhash::hash64(&key);
148154
let shift = util::ptr_size_bits() - self.ncb;
149-
155+
150156
(hash >> shift) as usize
151157
}
152158
} else {
@@ -158,11 +164,11 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
158164
{
159165
let hash = fxhash::hash64(&key);
160166
let shift = util::ptr_size_bits() - self.ncb;
161-
167+
162168
(hash >> shift) as usize
163169
}
164170
}
165-
}
171+
}
166172

167173
/// Inserts a key and a value into the map.
168174
///
@@ -368,9 +374,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
368374
/// stats.alter("Goals", |_, v| v * 2);
369375
/// assert_eq!(*stats.get("Goals").unwrap(), 8);
370376
/// ```
371-
///
377+
///
372378
/// # Panics
373-
///
379+
///
374380
/// If the given closure panics, then `alter_all` will abort the process
375381
#[inline]
376382
pub fn alter<Q>(&self, key: &Q, f: impl FnOnce(&K, V) -> V)
@@ -395,9 +401,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
395401
/// assert_eq!(*stats.get("Wins").unwrap(), 5);
396402
/// assert_eq!(*stats.get("Losses").unwrap(), 3);
397403
/// ```
398-
///
404+
///
399405
/// # Panics
400-
///
406+
///
401407
/// If the given closure panics, then `alter_all` will abort the process
402408
#[inline]
403409
pub fn alter_all(&self, f: impl FnMut(&K, V) -> V) {
@@ -454,7 +460,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> Map<'a, K, V> for DashMap<K, V> {
454460
fn _insert(&self, key: K, value: V) -> Option<V> {
455461
let idx = self.determine_map(&key);
456462
let mut shard = unsafe { self._yield_write_shard(idx) };
457-
shard.insert(key, SharedValue::new(value)).map(SharedValue::into_inner)
463+
shard
464+
.insert(key, SharedValue::new(value))
465+
.map(SharedValue::into_inner)
458466
}
459467

460468
#[inline]
@@ -523,7 +531,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> Map<'a, K, V> for DashMap<K, V> {
523531

524532
#[inline]
525533
fn _retain(&self, mut f: impl FnMut(&K, &mut V) -> bool) {
526-
self.shards.iter().for_each(|s| s.write().retain(|k, v| f(k, v.get_mut())));
534+
self.shards
535+
.iter()
536+
.for_each(|s| s.write().retain(|k, v| f(k, v.get_mut())));
527537
}
528538

529539
#[inline]

src/mapref/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::one::RefMut;
22
use crate::util;
3-
use crate::HashMap;
43
use crate::util::SharedValue;
4+
use crate::HashMap;
55
use parking_lot::RwLockWriteGuard;
66
use std::hash::Hash;
77
use std::mem;

src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! This module is full of hackery and dark magic.
22
//! Either spend a day fixing it and quietly submit a PR or don't mention it to anybody.
33
4-
use std::{mem, ptr};
54
use std::cell::UnsafeCell;
5+
use std::{mem, ptr};
66

77
#[inline(always)]
88
pub const fn ptr_size_bits() -> usize {
@@ -13,7 +13,7 @@ pub const fn ptr_size_bits() -> usize {
1313
pub fn map_in_place_2<T, U, F: FnOnce(U, T) -> T>((k, v): (U, &mut T), f: F) {
1414
unsafe {
1515
// # Safety
16-
//
16+
//
1717
// If the closure panics, we must abort otherwise we could double drop `T`
1818
let _promote_panic_to_abort = AbortOnPanic;
1919

@@ -78,4 +78,4 @@ impl Drop for AbortOnPanic {
7878
std::process::abort()
7979
}
8080
}
81-
}
81+
}

0 commit comments

Comments
 (0)