mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
use bitvec for group (internally)
This commit is contained in:
parent
990823e6b7
commit
3e38dc80f5
2 changed files with 14 additions and 4 deletions
|
@ -131,6 +131,16 @@ impl ReferenceMatrix {
|
||||||
|
|
||||||
/// Get the strongly-connected components of the set of input nodes.
|
/// Get the strongly-connected components of the set of input nodes.
|
||||||
pub fn strongly_connected_components(&self, nodes: &[u32]) -> Sccs {
|
pub fn strongly_connected_components(&self, nodes: &[u32]) -> Sccs {
|
||||||
|
let mut bitvec = BitVec::repeat(false, self.length);
|
||||||
|
|
||||||
|
for value in nodes {
|
||||||
|
bitvec.set(*value as usize, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.strongly_connected_components_help(&bitvec)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn strongly_connected_components_help(&self, nodes: &BitSlice) -> Sccs {
|
||||||
let mut params = Params::new(self.length, nodes);
|
let mut params = Params::new(self.length, nodes);
|
||||||
|
|
||||||
'outer: loop {
|
'outer: loop {
|
||||||
|
@ -180,11 +190,11 @@ struct Params {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Params {
|
impl Params {
|
||||||
fn new(length: usize, group: &[u32]) -> Self {
|
fn new(length: usize, group: &BitSlice) -> Self {
|
||||||
let mut preorders = vec![Preorder::Removed; length];
|
let mut preorders = vec![Preorder::Removed; length];
|
||||||
|
|
||||||
for value in group {
|
for index in group.iter_ones() {
|
||||||
preorders[*value as usize] = Preorder::Empty;
|
preorders[index] = Preorder::Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ pub fn load<'a>(
|
||||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||||
// When compiling to wasm, we cannot spawn extra threads
|
// When compiling to wasm, we cannot spawn extra threads
|
||||||
// so we have a single-threaded implementation
|
// so we have a single-threaded implementation
|
||||||
if threading == Threading::Single || cfg!(target_family = "wasm") {
|
if true || threading == Threading::Single || cfg!(target_family = "wasm") {
|
||||||
load_single_threaded(
|
load_single_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue