mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Avoid generating actual lambda names
This is super slow. When trying to compile a "real" app like rocci-bird or the false interpreter, the compiler will just hang in repeated calls to this function. I am not sure if this "fix" is valid. I would assume that hashing the names should be equivalent hashing the InLayout. The InLayout should be a unique id that maps to the layout. The layout should map to name. So I think it should be a fix. I haven't done intensive testing, but this is way way faster.
This commit is contained in:
parent
fc6b519b59
commit
50f220f878
1 changed files with 5 additions and 11 deletions
|
@ -358,27 +358,21 @@ trait Backend<'a> {
|
||||||
where
|
where
|
||||||
I: Iterator<Item = InLayout<'b>>,
|
I: Iterator<Item = InLayout<'b>>,
|
||||||
{
|
{
|
||||||
use std::fmt::Write;
|
|
||||||
use std::hash::{BuildHasher, Hash, Hasher};
|
use std::hash::{BuildHasher, Hash, Hasher};
|
||||||
|
|
||||||
let symbol = name.name();
|
let symbol = name.name();
|
||||||
|
|
||||||
let mut buf = String::with_capacity(1024);
|
// NOTE: due to randomness, this will not be consistent between runs
|
||||||
|
let mut state = roc_collections::all::BuildHasher::default().build_hasher();
|
||||||
for a in arguments {
|
for a in arguments {
|
||||||
write!(buf, "{:?}", self.interner().dbg_stable(a)).expect("capacity");
|
a.hash(&mut state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// lambda set should not matter; it should already be added as an argument
|
// lambda set should not matter; it should already be added as an argument
|
||||||
// but the niche of the lambda name may be the only thing differentiating two different
|
// but the niche of the lambda name may be the only thing differentiating two different
|
||||||
// implementations of a function with the same symbol
|
// implementations of a function with the same symbol
|
||||||
write!(buf, "{:?}", name.niche().dbg_stable(self.interner())).expect("capacity");
|
name.niche().hash(&mut state);
|
||||||
|
result.hash(&mut state);
|
||||||
write!(buf, "{:?}", self.interner().dbg_stable(result)).expect("capacity");
|
|
||||||
|
|
||||||
// NOTE: due to randomness, this will not be consistent between runs
|
|
||||||
let mut state = roc_collections::all::BuildHasher::default().build_hasher();
|
|
||||||
buf.hash(&mut state);
|
|
||||||
|
|
||||||
let interns = self.interns();
|
let interns = self.interns();
|
||||||
let ident_string = symbol.as_str(interns);
|
let ident_string = symbol.as_str(interns);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue