1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

perf/factor ~ tune number of stack inlined decomposition values (~1% time improvement)

This commit is contained in:
Roy Ivy III 2020-10-08 21:13:26 -05:00
parent 6eea8c5f30
commit 6a525c950d

View file

@ -20,9 +20,9 @@ type Exponent = u8;
struct Decomposition(SmallVec<[(u64, Exponent); NUM_FACTORS_INLINE]>); struct Decomposition(SmallVec<[(u64, Exponent); NUM_FACTORS_INLINE]>);
// The number of factors to inline directly into a `Decomposition` object. // The number of factors to inline directly into a `Decomposition` object.
// As a consequence of the ErdősKac theorem, the average number of prime // As a consequence of the ErdősKac theorem, the average number of prime factors
// factors of integers < 10²⁵ ≃ 2⁸³ is 4, so we can use that value. // of integers < 10²⁵ ≃ 2⁸³ is 4, so we can use a slightly higher value.
const NUM_FACTORS_INLINE: usize = 4; const NUM_FACTORS_INLINE: usize = 5;
impl Decomposition { impl Decomposition {
fn one() -> Decomposition { fn one() -> Decomposition {