Skip to content

Commit

Permalink
Turn FinGenAbGroupElem into a non-mutable struct
Browse files Browse the repository at this point in the history
This reduce allocations and increases speed of code using
these elements.
  • Loading branch information
fingolfin committed Sep 21, 2024
1 parent d9b7787 commit 3bcb770
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/GrpAb/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ end
#
################################################################################

# This destroy's the input. If you don't want this, use A(::ZZMatrix)

function FinGenAbGroupElem(A::FinGenAbGroup, a::ZZMatrix)
assure_reduced!(A, a)
z = FinGenAbGroupElem()
z.parent = A
z.coeff = a
return z
end

function reduce_mod_snf!(a::ZZMatrix, v::Vector{ZZRingElem})
GC.@preserve a begin
for i = 1:length(v)
Expand Down
9 changes: 7 additions & 2 deletions src/HeckeTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1828,11 +1828,16 @@ abstract type GrpAbElem <: AbstractAlgebra.AdditiveGroupElem end

end

mutable struct FinGenAbGroupElem <: GrpAbElem
struct FinGenAbGroupElem <: GrpAbElem
parent::FinGenAbGroup
coeff::ZZMatrix

FinGenAbGroupElem() = new()
# This destroy's the input. If you don't want this, use A(::ZZMatrix)
function FinGenAbGroupElem(A::FinGenAbGroup, a::ZZMatrix)
assure_reduced!(A, a)
return new(A, a)
end

end

################################################################################
Expand Down

0 comments on commit 3bcb770

Please sign in to comment.