Skip to content

Commit

Permalink
Merge pull request #387 from rafaqz/perf
Browse files Browse the repository at this point in the history
Performance tweaks
  • Loading branch information
rafaqz authored Jul 21, 2022
2 parents d29b530 + bd28d08 commit 2d96a1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Dimensions/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ _unwrapdim(x) = x
LookupArrays.selectindices(val(dim), val(seldim))

function _extent_as_selectors(extent::Extents.Extent{Keys}) where Keys
map(Keys, values(extent)) do k, v
rebuild(key2dim(k), LookupArrays.Interval(v...))
map(map(key2dim, Keys), values(extent)) do k, v
rebuild(k, LookupArrays.Interval(v...))
end
end
3 changes: 2 additions & 1 deletion src/Dimensions/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function slicedims end

@inline function _slicedims(f, dims::Tuple, refdims::Tuple, I::Tuple)
# Unnaligned may need grouped slicing
newdims, newrefdims = if any(d -> lookup(d) isa Unaligned, dims)
newdims, newrefdims = if any(map(d -> lookup(d) isa Unaligned, dims))
# Separate out unalligned dims
udims = _unalligned_dims(dims)
odims = otherdims(dims, udims)
Expand All @@ -403,6 +403,7 @@ function slicedims end
end
return newdims, (refdims..., newrefdims...)
end

@inline _slicedims(f, dims::Tuple, refdims::Tuple, I::Tuple{}) = dims, refdims
@inline _slicedims(f, dims::DimTuple, I::Tuple{}) = dims, ()
@inline _slicedims(f, dims::DimTuple, I::Tuple) = begin
Expand Down
4 changes: 3 additions & 1 deletion src/array/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ function Base._cat(catdims::Tuple, Xin::AbstractDimArray...)
cat_dnums = (inserted_dnums..., appended_dnums...)

newrefdims = otherdims(refdims(A1), newcatdims)
newA = Base._cat(cat_dnums, map(data, Xin)...)
T = Base.promote_eltypeof(Xin...)
data = map(parent, Xin)
newA = Base._cat_t(cat_dnums, T, data...)
rebuild(A1, newA, format(newdims, newA), newrefdims)
end
function Base._cat(catdim::DimType, Xin::AbstractDimArray...)
Expand Down

0 comments on commit 2d96a1b

Please sign in to comment.