From 50c97767eb226b5811e4bbbaa05a23197e9741e0 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 19 Jul 2022 02:00:28 +0200 Subject: [PATCH 1/3] use map with any for inference --- src/Dimensions/primitives.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Dimensions/primitives.jl b/src/Dimensions/primitives.jl index b21c63876..a51ee8f67 100644 --- a/src/Dimensions/primitives.jl +++ b/src/Dimensions/primitives.jl @@ -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) @@ -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 From 5e487ec40e19badb14a0a25a419c5ddc7dc2dd58 Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 19 Jul 2022 02:00:46 +0200 Subject: [PATCH 2/3] map over Keys tuple directly for constant prop --- src/Dimensions/indexing.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dimensions/indexing.jl b/src/Dimensions/indexing.jl index ed2c686ee..86c8d5c5d 100644 --- a/src/Dimensions/indexing.jl +++ b/src/Dimensions/indexing.jl @@ -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 From bd28d088d4db4684741a2b07816c708ff939c46e Mon Sep 17 00:00:00 2001 From: rafaqz Date: Tue, 19 Jul 2022 02:01:10 +0200 Subject: [PATCH 3/3] call _cat_t for better inference --- src/array/methods.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/array/methods.jl b/src/array/methods.jl index 6704f255e..1fe7fdde9 100644 --- a/src/array/methods.jl +++ b/src/array/methods.jl @@ -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...)