MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / par_resize_and_fill

Function par_resize_and_fill

splashsurf_lib/src/utils.rs:94–105  ·  view source on GitHub ↗
(
    vec: &mut Vec<T>,
    new_len: usize,
    value: T,
)

Source from the content-addressed store, hash-verified

92/// Resizes the given vector to the given length and fills new entries with `value.clone()`, parallel version
93#[allow(unused)]
94pub(crate) fn par_resize_and_fill<T: Clone + Send + Sync>(
95 vec: &mut Vec<T>,
96 new_len: usize,
97 value: T,
98) {
99 let old_len = vec.len();
100 vec.par_iter_mut()
101 .with_min_len(8)
102 .take(old_len.min(new_len))
103 .for_each(|v| *v = value.clone());
104 vec.resize(new_len, value);
105}
106
107pub struct ParallelPolicy {
108 pub min_task_size: usize,

Callers 1

resize_and_fillFunction · 0.85

Calls 4

for_eachMethod · 0.80
cloneMethod · 0.80
lenMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected