Skip to content

Commit

Permalink
inline?
Browse files Browse the repository at this point in the history
  • Loading branch information
Icerath committed Dec 25, 2024
1 parent 7017239 commit 652ed54
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/day24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
use std::hint::{assert_unchecked, unreachable_unchecked};
use tinyvec::ArrayVec;

#[inline(always)]
pub fn part1(input: &str) -> u64 {
unsafe { part1_inner(input.as_bytes()) }
}

#[inline(always)]
pub fn part2(input: &str) -> &'static str {
unsafe { part2_inner(input.as_bytes()) }
}
Expand All @@ -31,6 +33,7 @@ static mut IDS: [Option<u16>; ZEDS[0] as usize + 1] = [None; ZEDS[0] as usize +
static mut GATES: [Option<bool>; ZEDS[0] as usize + 1] = [None; ZEDS[0] as usize + 1];
static mut OPS: [(u16, u8, u16); ZEDS[0] as usize + 1] = [(0, 0, 0); ZEDS[0] as usize + 1];

#[inline(always)]
unsafe fn part1_inner(mut input: &[u8]) -> u64 {
let mut num_gates = 0;
while *input.get_unchecked(0) != b'\n' {
Expand Down Expand Up @@ -82,6 +85,7 @@ pub const PART2_OUT: &str = "cph,gws,hgj,nnt,npf,z13,z19,z33";
static mut XORS: [bool; ZEDS[0] as usize + 1] = [false; ZEDS[0] as usize + 1];
static mut ORS: [bool; ZEDS[0] as usize + 1] = [false; ZEDS[0] as usize + 1];

#[inline(always)]
unsafe fn part2_inner(mut input: &[u8]) -> &'static str {
static mut GATES: [(u16, u8, u16, u16); 1024] = [(0, 0, 0, 0); 1024];
while *input.get_unchecked(7) != b'\n' {
Expand Down

0 comments on commit 652ed54

Please sign in to comment.