Skip to content

Commit e5b5df1

Browse files
zero-systemsJohnTitor
authored andcommitted
Optimize vector fill in builder. (#89)
* optimize vector fill
1 parent dbfa13d commit e5b5df1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

actix-server/src/builder.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,14 @@ impl ServerBuilder {
263263
info!("Starting {} workers", self.threads);
264264

265265
// start workers
266-
let mut workers = Vec::new();
267-
for idx in 0..self.threads {
268-
let worker = self.start_worker(idx, self.accept.get_notify());
269-
workers.push(worker.clone());
270-
self.workers.push((idx, worker));
271-
}
266+
let workers = (0..self.threads)
267+
.map(|idx| {
268+
let worker = self.start_worker(idx, self.accept.get_notify());
269+
self.workers.push((idx, worker.clone()));
270+
271+
worker
272+
})
273+
.collect();
272274

273275
// start accept thread
274276
for sock in &self.sockets {
@@ -380,7 +382,7 @@ impl ServerBuilder {
380382
.await;
381383
System::current().stop();
382384
}
383-
.boxed(),
385+
.boxed(),
384386
);
385387
}
386388
ready(())

0 commit comments

Comments
 (0)