mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Feedback
This commit is contained in:
parent
5229edd742
commit
1caafbc131
1 changed files with 7 additions and 11 deletions
|
@ -117,8 +117,10 @@ struct Declaration<'a> {
|
||||||
impl<'a> Hash for Declaration<'a> {
|
impl<'a> Hash for Declaration<'a> {
|
||||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
self.symbol.hash(state);
|
self.symbol.hash(state);
|
||||||
// Only hash ths symbol, as it's faster and is almost always unique.
|
// Declaration is used as a key in DeclarationToIndex.
|
||||||
// If not unique, a slower equality comparison with the layout can be used.
|
// Only the symbol is hashed, as calculating the hash for the layout is slow.
|
||||||
|
// If the symbol is not unique (it collides with another symbol with a different value),
|
||||||
|
// a slower equality comparison will still include the layout.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,15 +162,9 @@ impl<'a> DeclarationToIndex<'a> {
|
||||||
let similar = self
|
let similar = self
|
||||||
.elements
|
.elements
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(
|
.filter_map(|(Declaration { symbol, layout }, _)| {
|
||||||
|(
|
(*symbol == needle_symbol).then_some(layout)
|
||||||
Declaration {
|
})
|
||||||
symbol: s,
|
|
||||||
layout: lay,
|
|
||||||
},
|
|
||||||
_,
|
|
||||||
)| if *s == needle_symbol { Some(lay) } else { None },
|
|
||||||
)
|
|
||||||
.collect::<std::vec::Vec<_>>();
|
.collect::<std::vec::Vec<_>>();
|
||||||
unreachable!(
|
unreachable!(
|
||||||
"symbol/layout {:?} {:#?} combo must be in DeclarationToIndex\nHowever {} similar layouts were found:\n{:#?}",
|
"symbol/layout {:?} {:#?} combo must be in DeclarationToIndex\nHowever {} similar layouts were found:\n{:#?}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue