From 91570ba6e85ae927f0979c0d2dde5684cb6823ff Mon Sep 17 00:00:00 2001 From: bokuweb Date: Wed, 29 Jun 2022 17:16:02 +0900 Subject: [PATCH] chore(cli): remove unnecessary unsafe in bench (#15000) --- cli/bench/http.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/cli/bench/http.rs b/cli/bench/http.rs index 3646f472c9..3735fde1bf 100644 --- a/cli/bench/http.rs +++ b/cli/bench/http.rs @@ -1,9 +1,9 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use super::Result; +use std::sync::atomic::{AtomicU16, Ordering}; use std::{collections::HashMap, path::Path, process::Command, time::Duration}; pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult}; - // Some of the benchmarks in this file have been renamed. In case the history // somehow gets messed up: // "node_http" was once called "node" @@ -150,18 +150,11 @@ fn run( Ok(parse_wrk_output(&output)) } +static NEXT_PORT: AtomicU16 = AtomicU16::new(4544); fn get_port() -> u16 { - static mut NEXT_PORT: u16 = 4544; - - // TODO(bartlomieju): - #[allow(clippy::undocumented_unsafe_blocks)] - let port = unsafe { - let p = NEXT_PORT; - NEXT_PORT += 1; - p - }; - - port + let p = NEXT_PORT.load(Ordering::SeqCst); + NEXT_PORT.store(p.wrapping_add(1), Ordering::SeqCst); + p } fn server_addr(port: u16) -> String {