We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 347d5fb commit e679494Copy full SHA for e679494
src/blockaxis.jl
@@ -63,6 +63,13 @@ _blocklengths2blocklasts(blocks) = cumsum(blocks) # extra level to allow changin
63
@inline blockedrange(blocks::Union{Tuple,AbstractVector}) = _BlockedUnitRange(_blocklengths2blocklasts(blocks))
64
65
@inline blockfirsts(a::BlockedUnitRange) = [a.first; @views(a.lasts[1:end-1]) .+ 1]
66
+# optimize common cases
67
+@inline function blockfirsts(a::BlockedUnitRange{<:Union{Vector, RangeCumsum{<:Any, <:UnitRange}}})
68
+ v = Vector{eltype(a)}(undef, length(a.lasts))
69
+ v[1] = a.first
70
+ v[2:end] .= @views(a.lasts[oneto(end-1)]) .+ 1
71
+ return v
72
+end
73
@inline blocklasts(a::BlockedUnitRange) = a.lasts
74
75
_diff(a::AbstractVector) = diff(a)
0 commit comments