Remove cache structs and use Tuples, allocating only when necessary #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes the old structs for caches (and thus the TLS sapproach) and uses the ideas from #20 to improve performance. All the predicates now try and use
Tuple
s for as long as possible and only allocate once an expansion could not be computed within 32 components. The modified code from Delaunator.jl in #20 works with some further fixes I mentioned in JuliaGeometry/Delaunator.jl#20.Since it is possible for expansions to be computed with length > 32 but then later derived expansions to have length < 32, for other predicates other than
incircle
it is not so simple to just check the length of a final expansion. Thus, for all expansions which could have a length exceeding 32, they are checked if they exceed that length and, if so, immediately allocate. This is made a bit easier with a@check_length
macro. The code is a bit cluttered with these checks but it's still fine for me to work with.Caches can still be provided manually to help reduce allocations a bit (although they are rare anyway), and so I made the cache functions public.
To also help with testing I defined (in the test functions not the package itself obviously) some failure vectors that stores test failures, and a
retry
function for retrying those failures.Will merge after I test it a bit more inside DelaunayTriangulation.jl.