Skip to content

Commit 9acfb0b

Browse files
lkdvosclaude
andcommitted
Construct TreeRows as TreeRows{F}(n)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fe20365 commit 9acfb0b

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

‎src/fusiontrees/braiding_manipulations.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function artin_braid!(U::AbstractMatrix, src::FusionTreeBlock{I, N, 0}, i; inv::
103103
isdual = src.isdual[1]
104104
isdual′ = TupleTools.setindex(isdual, isdual[i], i + 1)
105105
isdual′ = TupleTools.setindex(isdual′, isdual[i + 1], i)
106-
rows = TreeRows(fusiontreetype(I, N, 0), length(src))
106+
rows = TreeRows{fusiontreetype(I, N, 0)}(length(src))
107107

108108
oneT = one(sectorscalartype(I))
109109
fill!(U, zero(oneT))

‎src/fusiontrees/duality_manipulations.jl‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function bendright(src::FusionTreeBlock)
7171
N₂ = numin(src)
7272
@assert N₁ > 0
7373

74-
rows = TreeRows(fusiontreetype(I, N₁ - 1, N₂ + 1), length(src))
74+
rows = TreeRows{fusiontreetype(I, N₁ - 1, N₂ + 1)}(length(src))
7575
U = zeros(fusionscalartype(I), length(src), length(src))
7676

7777
for (col, (f₁, f₂)) in enumerate(fusiontrees(src))
@@ -140,7 +140,7 @@ function bendleft(src::FusionTreeBlock)
140140
N₂ = numin(src)
141141
@assert N₂ > 0
142142

143-
rows = TreeRows(fusiontreetype(I, N₁ + 1, N₂ - 1), length(src))
143+
rows = TreeRows{fusiontreetype(I, N₁ + 1, N₂ - 1)}(length(src))
144144
U = zeros(fusionscalartype(I), length(src), length(src))
145145

146146
for (col, (f₁, f₂)) in enumerate(fusiontrees(src))
@@ -220,7 +220,7 @@ function foldright(src::FusionTreeBlock)
220220
N₁ = numout(src)
221221
@assert N₁ > 0
222222

223-
rows = TreeRows(fusiontreetype(I, N₁ - 1, numin(src) + 1), length(src))
223+
rows = TreeRows{fusiontreetype(I, N₁ - 1, numin(src) + 1)}(length(src))
224224

225225
f₁, f₂ = first(fusiontrees(src))
226226
a::I = f₁.uncoupled[1]
@@ -298,7 +298,7 @@ function foldleft(src::FusionTreeBlock)
298298
N₂ = numout(src)
299299
@assert N₁ > 0
300300

301-
rows = TreeRows(fusiontreetype(I, N₂ + 1, N₁ - 1), length(src))
301+
rows = TreeRows{fusiontreetype(I, N₂ + 1, N₁ - 1)}(length(src))
302302

303303
f₁, f₂ = first(fusiontrees(src))
304304
a::I = f₂.uncoupled[1]

‎src/fusiontrees/fusiontrees.jl‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,12 @@ struct TreeRows{F, D}
299299
trees::Vector{F}
300300
index::Union{D, Nothing} # `nothing`: few trees, the rows are found by a linear search
301301
n::Int
302-
# no default outer constructor, of which `D` would be unbound if `index === nothing`
303-
TreeRows{F, D}(trees::Vector{F}, index, n::Int) where {F, D} = new{F, D}(trees, index, n)
304-
end
305-
function TreeRows(::Type{F}, n::Int) where {F}
306-
trees = sizehint!(Vector{F}(), n)
307-
K = Base.promote_op(treeindex_data, F)
308-
index = n > 32 ? sizehint!(Dict{K, Int}(), n) : nothing
309-
return TreeRows{F, Dict{K, Int}}(trees, index, n)
302+
function TreeRows{F}(n::Int) where {F}
303+
trees = sizehint!(Vector{F}(), n)
304+
K = Base.promote_op(treeindex_data, F)
305+
index = n > 32 ? sizehint!(Dict{K, Int}(), n) : nothing
306+
return new{F, Dict{K, Int}}(trees, index, n)
307+
end
310308
end
311309
function row!(rows::TreeRows, f)
312310
key = treeindex_data(f)

0 commit comments

Comments
 (0)