Skip to content

Commit

Permalink
Merge pull request #360 from cuviper/collect_vec_list
Browse files Browse the repository at this point in the history
Use rayon-1.9.0's `collect_vec_list`
  • Loading branch information
cuviper authored Nov 14, 2024
2 parents bf0362b + c095322 commit dceb0f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Downgrade dependencies
if: matrix.rust == '1.63.0'
run: |
cargo generate-lockfile
cargo update -p hashbrown --precise 0.15.0
- name: Tests
run: |
cargo build --verbose --features "${{ matrix.features }}"
Expand Down Expand Up @@ -83,6 +88,11 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Downgrade dependencies
if: matrix.rust == '1.63.0'
run: |
cargo generate-lockfile
cargo update -p hashbrown --precise 0.15.0
- name: Tests
run: |
cargo build -vv --target=${{ matrix.target }} --no-default-features
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ arbitrary = { version = "1.0", optional = true, default-features = false }
quickcheck = { version = "1.0", optional = true, default-features = false }
serde = { version = "1.0", optional = true, default-features = false }
borsh = { version = "1.2", optional = true, default-features = false }
rayon = { version = "1.5.3", optional = true }
rayon = { version = "1.9", optional = true }

# Internal feature, only used when building as part of rustc,
# not part of the stable interface of this crate.
Expand Down
15 changes: 1 addition & 14 deletions src/rayon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,5 @@ pub mod set;
// This form of intermediate collection is also how Rayon collects `HashMap`.
// Note that the order will also be preserved!
fn collect<I: IntoParallelIterator>(iter: I) -> LinkedList<Vec<I::Item>> {
iter.into_par_iter()
.fold(Vec::new, |mut vec, elem| {
vec.push(elem);
vec
})
.map(|vec| {
let mut list = LinkedList::new();
list.push_back(vec);
list
})
.reduce(LinkedList::new, |mut list1, mut list2| {
list1.append(&mut list2);
list1
})
iter.into_par_iter().collect_vec_list()
}

0 comments on commit dceb0f0

Please sign in to comment.