Skip to content

Commit 2601ba7

Browse files
authored
Turn FinGenAbGroupElem into a non-mutable struct (#1621)
This reduce allocations and increases speed of code using these elements.
1 parent d9b7787 commit 2601ba7

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/GrpAb/Elem.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ end
4444
#
4545
################################################################################
4646

47-
# This destroy's the input. If you don't want this, use A(::ZZMatrix)
48-
49-
function FinGenAbGroupElem(A::FinGenAbGroup, a::ZZMatrix)
50-
assure_reduced!(A, a)
51-
z = FinGenAbGroupElem()
52-
z.parent = A
53-
z.coeff = a
54-
return z
55-
end
56-
5747
function reduce_mod_snf!(a::ZZMatrix, v::Vector{ZZRingElem})
5848
GC.@preserve a begin
5949
for i = 1:length(v)

src/HeckeTypes.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,11 +1828,16 @@ abstract type GrpAbElem <: AbstractAlgebra.AdditiveGroupElem end
18281828

18291829
end
18301830

1831-
mutable struct FinGenAbGroupElem <: GrpAbElem
1831+
struct FinGenAbGroupElem <: GrpAbElem
18321832
parent::FinGenAbGroup
18331833
coeff::ZZMatrix
18341834

1835-
FinGenAbGroupElem() = new()
1835+
# This destroy's the input. If you don't want this, use A(::ZZMatrix)
1836+
function FinGenAbGroupElem(A::FinGenAbGroup, a::ZZMatrix)
1837+
assure_reduced!(A, a)
1838+
return new(A, a)
1839+
end
1840+
18361841
end
18371842

18381843
################################################################################

0 commit comments

Comments
 (0)