Skip to content

Commit ac7e284

Browse files
committed
Clean out vestiges of pre-0.7 support
1 parent e7ce34e commit ac7e284

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

src/Primes.jl

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This includes parts that were formerly a part of Julia. License is MIT: http://julialang.org/license
2-
VERSION < v"0.7.0-beta2.199" && __precompile__()
1+
# This file includes code that was formerly a part of Julia. License is MIT: http://julialang.org/license
2+
33
module Primes
44

55
using Base.Iterators: repeated
@@ -338,13 +338,8 @@ Set([2,5])
338338
"""
339339
factor(::Type{D}, n::T) where {T<:Integer, D<:AbstractDict} = factor!(n, D(Dict{T,Int}()))
340340
factor(::Type{A}, n::T) where {T<:Integer, A<:AbstractArray} = A(factor(Vector{T}, n))
341-
if VERSION >= v"0.7.0-beta.81"
342-
factor(::Type{Vector{T}}, n::T) where {T<:Integer} =
343-
mapreduce(collect, vcat, [repeated(k, v) for (k, v) in factor(n)], init=Vector{T}())
344-
else
345-
factor(::Type{Vector{T}}, n::T) where {T<:Integer} =
346-
mapreduce(collect, vcat, Vector{T}(), [repeated(k, v) for (k, v) in factor(n)])
347-
end
341+
factor(::Type{Vector{T}}, n::T) where {T<:Integer} =
342+
mapreduce(collect, vcat, [repeated(k, v) for (k, v) in factor(n)], init=Vector{T}())
348343
factor(::Type{S}, n::T) where {T<:Integer, S<:Union{Set,BitSet}} = S(keys(factor(n)))
349344
factor(::Type{T}, n) where {T<:Any} = throw(MethodError(factor, (T, n)))
350345

@@ -435,12 +430,6 @@ function pollardfactors!(n::T, h::AbstractDict{K,Int}) where {T<:Integer,K<:Inte
435430
end
436431
end
437432

438-
if VERSION >= v"0.7.0-beta.183"
439-
ndigits2(n) = ndigits(n, base=2)
440-
else
441-
ndigits2(n) = ndigits(n, 2)
442-
end
443-
444433
"""
445434
ismersenneprime(M::Integer; [check::Bool = true]) -> Bool
446435
@@ -461,7 +450,7 @@ true
461450
"""
462451
function ismersenneprime(M::Integer; check::Bool = true)
463452
if check
464-
d = ndigits2(M)
453+
d = ndigits(M, base=2)
465454
M >= 0 && isprime(d) && (M >> d == 0) ||
466455
throw(ArgumentError("The argument given is not a valid Mersenne Number (`M = 2^p - 1`)."))
467456
end
@@ -486,7 +475,7 @@ true
486475
```
487476
"""
488477
function isrieselprime(k::Integer, Q::Integer)
489-
n = ndigits2(Q)
478+
n = ndigits(Q, base=2)
490479
0 < k < Q || throw(ArgumentError("The condition 0 < k < Q must be met."))
491480
if k == 1 && isodd(n)
492481
return n % 4 == 3 ? ll_primecheck(Q, 3) : ll_primecheck(Q)
@@ -500,7 +489,7 @@ end
500489

501490
# LL backend -- not for export
502491
function ll_primecheck(X::Integer, s::Integer = 4)
503-
S, N = BigInt(s), BigInt(ndigits2(X))
492+
S, N = BigInt(s), BigInt(ndigits(X, base=2))
504493
X < 7 && throw(ArgumentError("The condition X ≥ 7 must be met."))
505494
for i in 1:(N - 2)
506495
S = (S^2 - 2) % X
@@ -543,12 +532,10 @@ end
543532

544533
# modify a BigInt in-place
545534
function add_!(n::BigInt, x::Int)
546-
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
547-
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
548535
if x < 0
549-
ccall((:__gmpz_sub_ui, :libgmp), Cvoid, (Any, Any, Culong), n, n, -x)
536+
ccall((:__gmpz_sub_ui, :libgmp), Cvoid, (Ref{BigInt}, Ref{BigInt}, Culong), n, n, -x)
550537
else
551-
ccall((:__gmpz_add_ui, :libgmp), Cvoid, (Any, Any, Culong), n, n, x)
538+
ccall((:__gmpz_add_ui, :libgmp), Cvoid, (Ref{BigInt}, Ref{BigInt}, Culong), n, n, x)
552539
end
553540
n
554541
end

0 commit comments

Comments
 (0)