Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Compat.@constprop and Compat.@inline #205

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name = "ArrayInterface"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "3.1.32"
version = "3.1.33"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"

[compat]
Compat = "3.37"
IfElse = "0.1"
Requires = "0.5, 1.0"
Static = "0.3.3"
Expand Down
11 changes: 1 addition & 10 deletions src/ArrayInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,11 @@ using Static
using Static: Zero, One, nstatic, _get_tuple, eq, ne, gt, ge, lt, le, eachop, eachop_tuple,
find_first_eq, permute, invariant_permutation
using Base.Cartesian
import Compat

using Base: @propagate_inbounds, tail, OneTo, LogicalIndex, Slice, ReinterpretArray,
ReshapedArray, AbstractCartesianIndex


## utilites for internal use only ##
@static if isdefined(Base, Symbol("@constprop"))
using Base: @constprop
else
macro constprop(_, ex)
ex
end
end

const CanonicalInt = Union{Int,StaticInt}

@static if VERSION ≥ v"1.6.0-DEV.1581"
Expand Down
8 changes: 4 additions & 4 deletions src/dimensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function from_parent_dims(::Type{R}) where {T,N,S,A,R<:ReinterpretArray{T,N,S,A}
end

from_parent_dims(x, dim) = from_parent_dims(typeof(x), dim)
@constprop :aggressive function from_parent_dims(::Type{T}, dim::Int)::Int where {T}
Compat.@constprop :aggressive function from_parent_dims(::Type{T}, dim::Int)::Int where {T}
if dim > ndims(T)
return static(ndims(parent_type(T)) + dim - ndims(T))
elseif dim > 0
Expand Down Expand Up @@ -127,7 +127,7 @@ function to_parent_dims(::Type{R}) where {T,N,S,A,R<:ReinterpretArray{T,N,S,A}}
end

to_parent_dims(x, dim) = to_parent_dims(typeof(x), dim)
@constprop :aggressive function to_parent_dims(::Type{T}, dim::Int)::Int where {T}
Compat.@constprop :aggressive function to_parent_dims(::Type{T}, dim::Int)::Int where {T}
if dim > ndims(T)
return static(ndims(parent_type(T)) + dim - ndims(T))
elseif dim > 0
Expand Down Expand Up @@ -200,7 +200,7 @@ function to_dims(::Type{T}, dim::StaticSymbol) where {T}
end
return i
end
@constprop :aggressive function to_dims(::Type{T}, dim::Symbol) where {T}
Compat.@constprop :aggressive function to_dims(::Type{T}, dim::Symbol) where {T}
i = find_first_eq(dim, map(Symbol, dimnames(T)))
if i === nothing
throw_dim_error(T, dim)
Expand All @@ -227,7 +227,7 @@ order_named_inds(x::Tuple, ::NamedTuple{(),Tuple{}}) = ()
function order_named_inds(x::Tuple, nd::NamedTuple{L}) where {L}
return order_named_inds(x, static(Val(L)), Tuple(nd))
end
@constprop :aggressive function order_named_inds(
Compat.@constprop :aggressive function order_named_inds(
x::Tuple{Vararg{Any,N}},
nd::Tuple,
inds::Tuple
Expand Down
2 changes: 1 addition & 1 deletion src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ end

function _generate_unsafe_get_index!_body(N::Int)
quote
Base.@_inline_meta
Compat.@inline()
D = eachindex(dest)
Dy = iterate(D)
@inbounds Base.Cartesian.@nloops $N j d -> I[d] begin
Expand Down