Skip to content

Commit 5a0b952

Browse files
Almost eliminate atomics
Another even more massive reduction of atomic ops. If your test needs build_data to run in parallel, this would change behaviour: the ids would no longer be intertwined. Instead now each loop assigns its contiguous block of ids.
1 parent 678440b commit 5a0b952

File tree

1 file changed

+5
-3
lines changed
  • frameworks/keyed/leptos/src

1 file changed

+5
-3
lines changed

frameworks/keyed/leptos/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ fn build_data(count: usize) -> Vec<RowData> {
5454
.map(|slice| slice.choose(&mut thread_rng).unwrap())
5555
.join(" ");
5656

57-
(0..count)
58-
.map(|_| RowData {
59-
id: ID_COUNTER.fetch_add(1, Ordering::Relaxed),
57+
let id = ID_COUNTER.fetch_add(count, Ordering::Relaxed);
58+
59+
(id..id + count)
60+
.map(|id| RowData {
61+
id,
6062
label: ArcRwSignal::new(label())
6163
})
6264
.collect()

0 commit comments

Comments
 (0)