Skip to content

Commit

Permalink
remove array!, use const to shorten array.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Bloom-dfinity committed Jul 25, 2021
1 parent b1a24d3 commit b552900
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion crossbeam-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ nightly = []
[dependencies]
cfg-if = "1"
lazy_static = { version = "1.4.0", optional = true }
array-macro = "2.1.0"

# Enable the use of loom for concurrency testing.
#
Expand Down
10 changes: 7 additions & 3 deletions crossbeam-utils/src/atomic/atomic_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![allow(clippy::let_unit_value)]

use crate::primitive::sync::atomic::{self, AtomicBool};
use array_macro::array;
use core::cell::UnsafeCell;
use core::fmt;
use core::mem;
Expand Down Expand Up @@ -684,8 +683,13 @@ fn lock(addr: usize) -> &'static SeqLock {
// stored at addresses that are multiples of 3. It'd be too bad if `LEN` was divisible by 3.
// In order to protect from such cases, we simply choose a large prime number for `LEN`.
const LEN: usize = 97;

static LOCKS: [SeqLock; LEN] = array![_ => SeqLock::new(); LEN];
const L: SeqLock = SeqLock::new();
static LOCKS: [SeqLock; LEN] = [
L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L,
L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L,
L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L,
L, L, L, L, L, L, L,
];

// If the modulus is a constant number, the compiler will use crazy math to transform this into
// a sequence of cheap arithmetic operations rather than using the slow modulo instruction.
Expand Down

0 comments on commit b552900

Please sign in to comment.