Skip to content

Remove cache structs and use Tuples, allocating only when necessary #21

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

Merged
merged 5 commits into from
Sep 15, 2024
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AdaptivePredicates"
uuid = "35492f91-a3bd-45ad-95db-fcad7dcfedb7"
authors = ["Valentin Churavy <v.churavy@gmail.com> and Daniel VandenHeuvel <danj.vandenheuvel@gmail.com"]
version = "1.1.1"
version = "1.2.0"

[compat]
julia = "1.6"
Expand Down
11 changes: 10 additions & 1 deletion src/AdaptivePredicates.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module AdaptivePredicates

@static if isdefined(Base, :Memory)
const Vec{T} = Memory{T}
else
const Vec{T} = Vector{T}
end

include("init.jl")
include("caches.jl")
include("macros.jl")
include("arithmetic.jl")
include("predicates.jl")
Expand All @@ -10,4 +15,8 @@ export orient2, orient3, incircle, insphere
export orient2p, orient3p, incirclep, inspherep
export orient2fast, orient3fast, incirclefast, inspherefast

if VERSION ≥ v"1.11.0-DEV.469"
eval(Meta.parse("public orient3adapt_cache, incircleadapt_cache, insphereexact_cache"))
end

end # module
8 changes: 4 additions & 4 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@inline setindex!!(tup::Tuple, value, index) = @inbounds Base.setindex(tup, value, index)
@inline setindex!!(tup::Tuple, value, index) = @inbounds index > length(tup) ? tup : Base.setindex(tup, value, index)
@inline setindex!!(vec::AbstractVector, value, index) = @inbounds Base.setindex!(vec, value, index)
@inline safe_getindex(e, eindex, elen) = eindex ≤ elen ? @inbounds(e[eindex]) : zero(eltype(e)) # Shewchuk's code is relying on undefined behaviour from out-of-bounds access where we call this. We need to be careful.
@inline safe_getindex(e, eindex, elen) = (eindex ≤ elen && eindex ≤ length(e)) ? @inbounds(e[eindex]) : zero(eltype(e)) # Shewchuk's code is relying on undefined behaviour from out-of-bounds access where we call this. We need to be careful.

function grow_expansion(elen, e, b, h)
@inbounds begin
Expand Down Expand Up @@ -197,8 +197,8 @@ function fast_expansion_sum_zeroelim(elen, e, flen, f, h)
fnow = f[1]
eindex = findex = 1
if (fnow > enow) == (fnow > -enow)
Q = enow
eindex += 1
Q = enow
eindex += 1
enow = safe_getindex(e, eindex, elen)
else
Q = fnow
Expand Down
300 changes: 0 additions & 300 deletions src/caches.jl

This file was deleted.

Loading