-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Deprecate the FxHashMap()
and FxHashSet()
constructor function hack
#55114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ee81739
3c9258e
5075174
36641ce
55f7662
ab3f37e
54eb222
bf3d40a
53e92f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,19 +169,21 @@ impl Ord for Interned<String> { | |
} | ||
} | ||
|
||
struct TyIntern<T> { | ||
struct TyIntern<T: Hash + Clone + Eq> { | ||
items: Vec<T>, | ||
set: HashMap<T, Interned<T>>, | ||
} | ||
|
||
impl<T: Hash + Clone + Eq> TyIntern<T> { | ||
fn new() -> TyIntern<T> { | ||
impl<T: Hash + Clone + Eq> Default for TyIntern<T> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be derived? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No; the derived A comment saying so might be a good idea though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get it |
||
fn default() -> Self { | ||
TyIntern { | ||
items: Vec::new(), | ||
set: HashMap::new(), | ||
set: Default::default(), | ||
} | ||
} | ||
} | ||
|
||
impl<T: Hash + Clone + Eq> TyIntern<T> { | ||
fn intern_borrow<B>(&mut self, item: &B) -> Interned<T> | ||
where | ||
B: Eq + Hash + ToOwned<Owned=T> + ?Sized, | ||
|
@@ -212,19 +214,13 @@ impl<T: Hash + Clone + Eq> TyIntern<T> { | |
} | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct Interner { | ||
strs: Mutex<TyIntern<String>>, | ||
paths: Mutex<TyIntern<PathBuf>>, | ||
} | ||
|
||
impl Interner { | ||
fn new() -> Interner { | ||
Interner { | ||
strs: Mutex::new(TyIntern::new()), | ||
paths: Mutex::new(TyIntern::new()), | ||
} | ||
} | ||
|
||
pub fn intern_str(&self, s: &str) -> Interned<String> { | ||
self.strs.lock().unwrap().intern_borrow(s) | ||
} | ||
|
@@ -238,7 +234,7 @@ impl Interner { | |
} | ||
|
||
lazy_static! { | ||
pub static ref INTERNER: Interner = Interner::new(); | ||
pub static ref INTERNER: Interner = Interner::default(); | ||
} | ||
|
||
/// This is essentially a HashMap which allows storing any type in its input and | ||
|
Uh oh!
There was an error while loading. Please reload this page.