Skip to content

Commit

Permalink
Fix fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
byeongkeunahn committed Sep 21, 2024
1 parent 0ecfa79 commit 2841ed5
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 51 deletions.
2 changes: 1 addition & 1 deletion basm-macro/src/import.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use proc_macro2::TokenStream;
use quote::quote;
use syn::{
parse::{Parse, ParseStream},
Result, Signature, Token,
parse::{Parse, ParseStream},
};

use super::types::{Mangle, TFunction};
Expand Down
4 changes: 2 additions & 2 deletions basm-std/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ impl<T> DfsIter<T> for JaggedDfsIter {
}

fn to(&self, graph: &Self::G) -> Self::V {
graph.link[self.1 as usize].1 .0 as usize
graph.link[self.1 as usize].1.0 as usize
}

fn id(&self, _: &Self::G) -> Self::E {
self.1 as usize
}

fn data<'a>(&self, graph: &'a Self::G) -> &'a T {
&graph.link[self.1 as usize].1 .1
&graph.link[self.1 as usize].1.1
}

fn next(&mut self, graph: &Self::G) -> bool {
Expand Down
8 changes: 4 additions & 4 deletions basm-std/src/math/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ mod test {
1614279433659886989,
2232618956921417485
],
multiply_u64(
&[2745895686766400144, 7520886206723962441],
&[9006621652498007052, 5476023620144815056]
)
multiply_u64(&[2745895686766400144, 7520886206723962441], &[
9006621652498007052,
5476023620144815056
])
);
}
#[test]
Expand Down
18 changes: 3 additions & 15 deletions basm-std/src/math/ntt/nttcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ impl<const P: u64> Arith<P> {
let m = (x as u64).wrapping_mul(Self::PINV);
let y = ((m as u128 * P as u128) >> 64) as u64;
let (out, overflow) = ((x >> 64) as u64).overflowing_sub(y);
if overflow {
out.wrapping_add(P)
} else {
out
}
if overflow { out.wrapping_add(P) } else { out }
}
// Multiplication with Montgomery reduction:
// a * b * R^-1 mod P
Expand Down Expand Up @@ -145,11 +141,7 @@ impl<const P: u64> Arith<P> {
// Computes a + b mod P, output range [0, 2^64)
pub const fn addmod64(a: u64, b: u64) -> u64 {
let (out, overflow) = a.overflowing_add(b);
if overflow {
out.wrapping_sub(P)
} else {
out
}
if overflow { out.wrapping_sub(P) } else { out }
}
// Computes a + b mod P, selects addmod64 or addmod depending on INV && TWIDDLE
pub const fn addmodopt_invtw<const INV: bool, const TWIDDLE: bool>(a: u64, b: u64) -> u64 {
Expand All @@ -162,11 +154,7 @@ impl<const P: u64> Arith<P> {
// Computes a - b mod P, output range [0, P)
pub const fn submod(a: u64, b: u64) -> u64 {
let (out, overflow) = a.overflowing_sub(b);
if overflow {
out.wrapping_add(P)
} else {
out
}
if overflow { out.wrapping_add(P) } else { out }
}
}

Expand Down
2 changes: 1 addition & 1 deletion basm-std/src/math/pollard_rho.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::math::{
gcd, is_prime_u64,
miller_rabin::{OddMont, M},
miller_rabin::{M, OddMont},
};
use alloc::{vec, vec::Vec};

Expand Down
6 changes: 1 addition & 5 deletions basm-std/src/math/sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,7 @@ impl LinearSieve {

fn next_len(cur_upto: usize, x: usize) -> usize {
let out = cur_upto + (cur_upto >> 1) + 1;
if x > out {
x
} else {
out
}
if x > out { x } else { out }
}
}

Expand Down
4 changes: 3 additions & 1 deletion basm-std/src/platform/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ use crate::platform::loader;
compile_error!("The target architecture is not supported.");

#[cfg(all(target_arch = "aarch64", feature = "submit"))]
compile_error!("AArch64 (aarch64-apple-darwin) is only supported for local execution, not submission; use x86-64 to submit.");
compile_error!(
"AArch64 (aarch64-apple-darwin) is only supported for local execution, not submission; use x86-64 to submit."
);

#[cfg(all(target_arch = "x86_64", not(target_os = "windows")))]
#[unsafe(no_mangle)]
Expand Down
6 changes: 1 addition & 5 deletions basm-std/src/platform/io/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,7 @@ impl<const N: usize> ReaderTrait for Reader<N> {
let s = unsafe { core::str::from_utf8_unchecked(s_u8) };
let out = f64::from_str(s);
self.skip_until_whitespace();
if let Ok(ans) = out {
ans
} else {
f64::NAN
}
if let Ok(ans) = out { ans } else { f64::NAN }
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions basm-std/src/platform/malloc/dlmalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1847,11 +1847,7 @@ impl TreeChunk {
unsafe fn leftmost_child(me: *mut TreeChunk) -> *mut TreeChunk {
unsafe {
let left = (*me).child[0];
if left.is_null() {
(*me).child[1]
} else {
left
}
if left.is_null() { (*me).child[1] } else { left }
}
}

Expand Down
12 changes: 2 additions & 10 deletions basm-std/src/utils/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,7 @@ impl F64Ops for f64 {
#[inline]
fn rem_euclid(self, rhs: f64) -> f64 {
let r = self % rhs;
if r < 0.0 {
r + rhs.abs()
} else {
r
}
if r < 0.0 { r + rhs.abs() } else { r }
}

/// Raises a number to an integer power.
Expand Down Expand Up @@ -377,11 +373,7 @@ impl F64Ops for f64 {
powx *= powx;
m /= 2;
}
if n < 0 {
1.0 / r
} else {
r
}
if n < 0 { 1.0 / r } else { r }
}

/// Raises a number to a floating point power.
Expand Down
6 changes: 4 additions & 2 deletions basm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ fn main() {
let stdout = String::from_utf8_lossy(&output.stdout);
let stdout = stdout.trim();
if !stdout.contains("x86_64-w64-mingw32-gcc") {
panic!("Failed to locate MinGW64 (x86_64-w64-mingw32-gcc).\n{0}",
"Please make sure MinGW64 is installed and added in the PATH environment variable.");
panic!(
"Failed to locate MinGW64 (x86_64-w64-mingw32-gcc).\n{0}",
"Please make sure MinGW64 is installed and added in the PATH environment variable."
);
}
link_args_basm.push("-nostartfiles");
link_args_basm.push("-nostdlib");
Expand Down

0 comments on commit 2841ed5

Please sign in to comment.