Skip to content

Commit 91570ba

Browse files
authored
chore(cli): remove unnecessary unsafe in bench (#15000)
1 parent 76d387f commit 91570ba

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

cli/bench/http.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
22

33
use super::Result;
4+
use std::sync::atomic::{AtomicU16, Ordering};
45
use std::{collections::HashMap, path::Path, process::Command, time::Duration};
56
pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult};
6-
77
// Some of the benchmarks in this file have been renamed. In case the history
88
// somehow gets messed up:
99
// "node_http" was once called "node"
@@ -150,18 +150,11 @@ fn run(
150150
Ok(parse_wrk_output(&output))
151151
}
152152

153+
static NEXT_PORT: AtomicU16 = AtomicU16::new(4544);
153154
fn get_port() -> u16 {
154-
static mut NEXT_PORT: u16 = 4544;
155-
156-
// TODO(bartlomieju):
157-
#[allow(clippy::undocumented_unsafe_blocks)]
158-
let port = unsafe {
159-
let p = NEXT_PORT;
160-
NEXT_PORT += 1;
161-
p
162-
};
163-
164-
port
155+
let p = NEXT_PORT.load(Ordering::SeqCst);
156+
NEXT_PORT.store(p.wrapping_add(1), Ordering::SeqCst);
157+
p
165158
}
166159

167160
fn server_addr(port: u16) -> String {

0 commit comments

Comments
 (0)