Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mdf performance and docs #1438

Merged
merged 10 commits into from
Feb 14, 2024
Prev Previous commit
Next Next commit
Comparing against zero is slightly faster
  • Loading branch information
pitdicker committed Feb 14, 2024
commit 6545c6f03b489373dc3b371c0d20e23beeab3546
4 changes: 2 additions & 2 deletions src/naive/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub(super) const MAX_MDL: u32 = (12 << 6) | (31 << 1) | 1;
// The next table are adjustment values to convert a date encoded as month-day-leapyear to
// ordinal-leapyear. OL = MDL - adjustment.
// Dates that do not exist are encoded as `XX`.
const XX: i8 = -128;
const XX: i8 = 0;
const MDL_TO_OL: &[i8; MAX_MDL as usize + 1] = &[
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,
XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX,
Expand Down Expand Up @@ -255,7 +255,7 @@ impl Mdf {
let mdl = mdf >> 3;
if mdl <= MAX_MDL {
// Array is indexed from `[1..=MAX_MDL]`, with a `0` index having a meaningless value.
MDL_TO_OL[mdl as usize] >= 0
MDL_TO_OL[mdl as usize] > 0
} else {
// Panicking here would be reasonable, but we are just going on with a safe value.
false
Expand Down