Skip to content

Commit

Permalink
Merge pull request #163 from kalmarek/setindex-cleanup
Browse files Browse the repository at this point in the history
Make setindex! always use set!
  • Loading branch information
Joel-Dahne authored Aug 4, 2023
2 parents a9c2406 + 9273ff9 commit 8a0be1a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Base.@propagate_inbounds function Base.setindex!(
i::Integer,
j::Integer,
)
@boundscheck checkbounds(A, i, j)
ref(A, i, j)[] = x
return x
end
Expand Down Expand Up @@ -97,7 +96,6 @@ Base.@propagate_inbounds function Base.setindex!(
i::Integer,
j::Integer,
)
@boundscheck checkbounds(A, i, j)
ref(A, i, j)[] = x
return x
end
Expand Down
3 changes: 3 additions & 0 deletions src/setters.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Use res[] = x as short hand for Arblib.set!(res, x)
Base.setindex!(res::Union{MagLike,ArfLike,ArbLike,AcbLike}, x) = set!(res, x)

# Mag
set!(res::MagLike, x::Integer) = set!(res, convert(UInt, x))
set!(res::MagLike, ::Irrational{:π}) = const_pi!(res)
Expand Down
7 changes: 0 additions & 7 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,3 @@ const ArbTypes = Union{
AcbPoly,
AcbSeries,
}

Base.setindex!(x::Union{Mag,MagRef,Arf,ArfRef,Arb,ArbRef,Acb,AcbRef}, z::Number) =
set!(x, z)
Base.setindex!(x::MagOrRef, z::Ptr{mag_struct}) = set!(x, z)
Base.setindex!(x::ArfOrRef, z::Ptr{arf_struct}) = set!(x, z)
Base.setindex!(x::ArbOrRef, z::Ptr{arb_struct}) = set!(x, z)
Base.setindex!(x::AcbOrRef, z::Ptr{acb_struct}) = set!(x, z)
2 changes: 0 additions & 2 deletions src/vector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Base.@propagate_inbounds function Base.setindex!(
x,
i::Integer,
)
@boundscheck checkbounds(v, i)
ref(v, i)[] = x
return x
end
Expand Down Expand Up @@ -84,7 +83,6 @@ Base.@propagate_inbounds function Base.setindex!(
x,
i::Integer,
)
@boundscheck checkbounds(v, i)
ref(v, i)[] = x
return x
end
Expand Down

0 comments on commit 8a0be1a

Please sign in to comment.