-
Notifications
You must be signed in to change notification settings - Fork 40
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
add offset overflow check #144
Conversation
aae4988
to
e7d1875
Compare
Codecov Report
@@ Coverage Diff @@
## master #144 +/- ##
==========================================
+ Coverage 91.39% 92.64% +1.25%
==========================================
Files 2 2
Lines 244 272 +28
==========================================
+ Hits 223 252 +29
+ Misses 21 20 -1
Continue to review full report at Codecov.
|
src/OffsetArrays.jl
Outdated
end | ||
OffsetVector{T,AA<:AbstractArray} = OffsetArray{T,1,AA} | ||
OffsetMatrix{T,AA<:AbstractArray} = OffsetArray{T,2,AA} | ||
|
||
function overflow_check(r, offset::T) where T | ||
throw_offseterror() = throw(ArgumentError("Boundary overflow detected: offset $offset should be smaller than $(typemax(T) - last(r))")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why define a function for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears to improve the performance, not entirely sure why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened a new issue in JuliaLang/julia#37558
In this PR I just switched back to the simple version and don't tweak it; IMO 5-10ns difference isn't critical to our use case.
Although this is related to overflow behavior in IdOffsetRange, the better place to raise an error is at the construction time of OffsetArray.
Performance overhead should be acceptable:
closes #136