From fcae8246e96b331efea41286e82ff0591b58d79c Mon Sep 17 00:00:00 2001 From: byhill Date: Thu, 22 Feb 2024 17:15:58 -0700 Subject: [PATCH] Remove type-converting primes from eachfactor --- Project.toml | 4 ++-- src/ModularSquareRoots.jl | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 16b867a..8187f7b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,11 +1,11 @@ name = "ModularSquareRoots" uuid = "544cf62c-00ce-4949-a641-e1b79df66db1" authors = ["byhill and contributors"] -version = "0.1.2" +version = "0.1.3" [deps] Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae" [compat] -Primes = "0.5" +Primes = "0.5.6" julia = "1.8" diff --git a/src/ModularSquareRoots.jl b/src/ModularSquareRoots.jl index b3a942a..38a60b3 100644 --- a/src/ModularSquareRoots.jl +++ b/src/ModularSquareRoots.jl @@ -63,17 +63,13 @@ function sqrtmod(n::T, m::T) where {T<:Integer} newroots = T[] mm = one(T) for (p, e) in eachfactor(m) - - # Unfortunately, `eachfactor` is not type-stable at the moment. - # Therefore, we need to wrap `p` to be of type `T`. - # See https://github.com/JuliaMath/Primes.jl/issues/151 for a1 in _sqrtmodq(n, T(p), e) for a2 in roots - push!(newroots, crt([a1, a2], [T(p)^e, mm], T(p)^e * mm)) + push!(newroots, crt([a1, a2], [p^e, mm], p^e * mm)) end end - mm *= T(p)^e + mm *= p^e roots, newroots = newroots, roots empty!(newroots) end