Skip to content

Commit 12e2c60

Browse files
authored
improve type-stability in blocklengths (#264)
* improve type-stability in blocklengths * bump version to v0.16.31
1 parent ca62df2 commit 12e2c60

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockArrays"
22
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
3-
version = "0.16.30"
3+
version = "0.16.31"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/blockaxis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ _blocklengths2blocklasts(blocks) = cumsum(blocks) # extra level to allow changin
6565

6666
_diff(a::AbstractVector) = diff(a)
6767
_diff(a::Tuple) = diff(collect(a))
68-
@inline blocklengths(a::BlockedUnitRange) = isempty(a.lasts) ? _diff(a.lasts) : [first(a.lasts)-a.first+1; _diff(a.lasts)]
68+
@inline blocklengths(a::BlockedUnitRange) = isempty(a.lasts) ? [_diff(a.lasts);] : [first(a.lasts)-a.first+1; _diff(a.lasts)]
6969

7070
length(a::BlockedUnitRange) = isempty(a.lasts) ? 0 : Integer(last(a.lasts)-a.first+1)
7171

test/test_blockindices.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ end
171171
@test blocklengths(f) Fill(2,5)
172172

173173
r = blockedrange(Base.OneTo(5))
174+
@test (@inferred blocklengths(r)) == 1:5
174175
@test blocklasts(r) ArrayLayouts.RangeCumsum(Base.OneTo(5))
175176
end
176177

0 commit comments

Comments
 (0)