JuliaArrays / FillArrays.jl

Julia package for lazily representing matrices filled with a single entry
https://juliaarrays.github.io/FillArrays.jl/
MIT License
181 stars 38 forks source link

Specialize isassigned for AbstractFill #351

Closed jishnub closed 6 months ago

jishnub commented 8 months ago

Since an AbstractFill is by definition filled with values, we may short-circuit isassigned:

julia> F = Fill(3, 100, 100);

julia> @btime isassigned($(Ref(F))[], 1, 1)
  24.297 ns (0 allocations: 0 bytes) # master
  3.360 ns (0 allocations: 0 bytes) # PR
codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.90%. Comparing base (99278fa) to head (e36922a). Report is 16 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #351 +/- ## ======================================= Coverage 99.90% 99.90% ======================================= Files 8 8 Lines 1037 1061 +24 ======================================= + Hits 1036 1060 +24 Misses 1 1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

longemen3000 commented 8 months ago

seems good to merge, at first i thought that this would affect OneElement, but that type subtypes AbstractArray instead

jishnub commented 6 months ago

I've specialized isassigned for a OneElement as well, as the same logic would apply. Since the array is always initialized with a value, the elements should all be assigned as long as they are in range.