Skip to content

Commit 50a3610

Browse files
committed
More statics
1 parent 98cf199 commit 50a3610

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/day10.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ pub fn part1(s: &str) -> u32 {
1111
static mut MAPS_PART1: [[u64; BIG_SIZE]; 9] = [[0; BIG_SIZE]; 9];
1212
static mut MAPS_PART2: [[u16; BIG_SIZE]; 9] = [[0; BIG_SIZE]; 9];
1313

14+
static mut POSITIONS_PART1: [(u16, [u16; MAX_SIZE * MAX_SIZE / 9]); 9] =
15+
[(0u16, [0u16; MAX_SIZE * MAX_SIZE / 9]); 9];
16+
static mut POSITIONS_PART2: [(u16, [u16; MAX_SIZE * MAX_SIZE / 9]); 9] =
17+
[(0u16, [0u16; MAX_SIZE * MAX_SIZE / 9]); 9];
18+
1419
#[target_feature(enable = "avx2,bmi1,bmi2,cmpxchg16b,lzcnt,movbe,popcnt")]
1520
unsafe fn part1_inner(s: &str) -> u32 {
1621
let s = s.as_bytes();
1722

18-
let mut positions = [(0u16, [0u16; MAX_SIZE * MAX_SIZE / 9]); 9];
19-
let maps = &mut MAPS_PART1;
23+
let positions = &mut *(&raw mut POSITIONS_PART1);
24+
let maps = &mut *(&raw mut MAPS_PART1);
2025
let mut zero_pos = 0;
2126

2227
let mut y = 0;
@@ -84,8 +89,8 @@ pub fn part2(s: &str) -> u16 {
8489
unsafe fn part2_inner(s: &str) -> u16 {
8590
let s = s.as_bytes();
8691

87-
let mut positions = [(0u16, [0u16; MAX_SIZE * MAX_SIZE / 9]); 9];
88-
let mut maps = &mut MAPS_PART2;
92+
let positions = &mut *(&raw mut POSITIONS_PART2);
93+
let maps = &mut *(&raw mut MAPS_PART2);
8994

9095
let mut y = 0;
9196
let mut x = 0;

0 commit comments

Comments
 (0)