avoid push_back in loops
Detected by clang-tidy.
This commit is contained in:
parent
cf800a35da
commit
79409eb6fe
@ -34,14 +34,12 @@ main (void)
|
||||
{
|
||||
util::job::queue q {std::thread::hardware_concurrency (), INNER};
|
||||
std::vector<util::job::queue::cookie> cookies;
|
||||
for (int j = 0; j < INNER; ++j) {
|
||||
cookies.push_back (
|
||||
q.submit (
|
||||
sleep_inc,
|
||||
std::ref (count)
|
||||
)
|
||||
std::generate_n (std::back_inserter (cookies), INNER, [&] () {
|
||||
return q.submit (
|
||||
sleep_inc,
|
||||
std::ref (count)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
success = count == INNER && success;
|
||||
|
@ -60,8 +60,13 @@ main ()
|
||||
};
|
||||
|
||||
std::vector<std::thread> workers;
|
||||
for (int i = 0; i < parallelism; ++i)
|
||||
workers.emplace_back (func, i);
|
||||
std::generate_n (
|
||||
std::back_inserter (workers),
|
||||
parallelism,
|
||||
[&, i = 0] () mutable
|
||||
{
|
||||
return std::thread { func, i++ };
|
||||
});
|
||||
|
||||
for (auto &t: workers)
|
||||
t.join ();
|
||||
|
Loading…
Reference in New Issue
Block a user