Skip to content

Commit 1479dbc

Browse files
authored
prealocate space
1 parent 25371c5 commit 1479dbc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/factorization.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
struct Factorization{T<:Integer} <: AbstractDict{T, Int}
55
pe::Vector{Pair{T, Int}} # Prime-Exponent
66

7-
Factorization{T}() where {T<:Integer} = new{T}(Vector{Pair{T, Int}}())
7+
function Factorization{T}() where {T<:Integer}
8+
# preallocates enough space that numbers smaller than 2310 won't need to resize
9+
v = Vector{Pair{T, Int}}(undef, 4)
10+
empty!(v)
11+
new{T}(v)
12+
end
813
end
914

1015
function Factorization{T}(d::AbstractDict) where T<:Integer

0 commit comments

Comments
 (0)