Skip to content

Commit efd12cf

Browse files
authored
Reduce allocations in blocklengths (#551)
1 parent a408d0b commit efd12cf

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Spaces/SubSpace.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@ block(sp::SubSpace, k::Integer) = block(sp.space,reindex(sp,(sp.indexes,),(k,))[
2626
function blocklengths(sp::SubSpace{DS,UnitRange{Int}}) where DS
2727
N = first(sp.indexes)
2828
M = last(sp.indexes)
29-
B1=block(sp.space,N)
30-
B2=block(sp.space,M)
29+
B1 = block(sp.space,N)
30+
B2 = block(sp.space,M)
3131
# if the blocks are equal, we have only one bvlock
32-
B1 == B2 && return [zeros(Int,B1.n[1]-1);length(sp.indexes)]
32+
B1 == B2 && return [Zeros{Int}(B1.n[1]-1); length(sp.indexes)]
3333

34-
[zeros(Int,B1.n[1]-1);
35-
blockstop(sp.space,B1)-N+1;blocklengths(sp.space)[B1.n[1]+1:B2.n[1]-1];
34+
[Zeros{Int}(B1.n[1]-1);
35+
blockstop(sp.space,B1)-N+1;
36+
blocklengths(sp.space)[B1.n[1]+1:B2.n[1]-1];
3637
M-blockstart(sp.space,B2)+1]
3738
end
3839

3940
function blocklengths(sp::SubSpace{DS,<:AbstractInfUnitRange{Int}}) where DS
4041
N = first(sp.indexes)
41-
B1=block(sp.space,N)
42+
B1 = block(sp.space,N)
4243

43-
Vcat([zeros(Int,B1.n[1]-1); blockstop(sp.space,B1)-N+1],
44+
Vcat([Zeros{Int}(B1.n[1]-1); blockstop(sp.space,B1)-N+1],
4445
blocklengths(sp.space)[B1.n[1]+1:∞])
4546
end
4647

0 commit comments

Comments
 (0)