fix and refactor Arrays.getindex!#1213
Open
Antoinemarteau wants to merge 5 commits intogridap:masterfrom
Open
Conversation
getindex! would ignore the cache if the given indices did not match the `IndexStyle` of the array. Now, the indices are converted using LinearIndices or CartesianIndices. This also cleans the implementation by using @propagate_inbounds, limiting number of method and using Base to transform the indices.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1213 +/- ##
==========================================
- Coverage 89.04% 88.97% -0.07%
==========================================
Files 213 213
Lines 27529 27556 +27
==========================================
+ Hits 24512 24519 +7
- Misses 3017 3037 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- marked most `getindex`, `getindex!` and `setindex!` method @propagate_inbounds - optimized these method with `@inbounds` where usefull - added a lot of `@inbounds` where safe (use of `eachindex`/ via @check of Array sizes), - especially in `ArrayBlocks` (those `@inbounds` rely on the fields of `ArrayBlock` being `Base.Array`, more precisely that they are 1-based indexed and of `IndexLinear` style) - some more `@inbounds` are probably possible in `Tables.jl`
Contributor
Author
|
I also took the opportunity to add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
getindex!would ignore the cache if the given indices did not match theIndexStyleof the array. This could lead to re-alocating the cache ofLazyArrays at each access in hot loops.Now, the indices are converted using LinearIndices or CartesianIndices, so the cache should never be ignored if the indices index a single element in the array.
This also cleans the implementation by using @propagate_inbounds, limiting number of method and using Base to transform the indices.