-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
improve performance of complex number parsing #35727
Conversation
Codecov Report
@@ Coverage Diff @@
## master #35727 +/- ##
=======================================
Coverage 86.14% 86.14%
=======================================
Files 346 346
Lines 64615 64617 +2
=======================================
+ Hits 55663 55666 +3
+ Misses 8952 8951 -1
Continue to review full report at Codecov.
|
Wouldn't it be better to just speed up |
For that matter, even the function findnext(testf::Function, s::AbstractString, i::Integer)
z = ncodeunits(s) + 1
1 ≤ i ≤ z || throw(BoundsError(s, i))
@inbounds i == z || isvalid(s, i) || string_index_err(s, i)
e = lastindex(s)
@inbounds while i < e
testf(s[i]) && return i
i = nextind(s, i)
end
return nothing
end
function findprev(testf::Function, s::AbstractString, i::Integer)
z = ncodeunits(s) + 1
0 ≤ i ≤ z || throw(BoundsError(s, i))
i == z && return nothing # current behavior, but seems a bit odd?
@inbounds i == 0 || isvalid(s, i) || string_index_err(s, i)
@inbounds while i > 1
testf(s[i]) && return i
i = prevind(s, i)
end
return nothing
end (Note that returning |
In fact, a lot of the code in |
It would be interesting to know if this got faster since we can now stack allocate those objects. |
Mission accomplished ;) |
Before:
After
It is still very slow but hey.
Ref #35721
The super slowness came from the generic
findprev
which needs to allocate a brand new string to for the reversal:julia/base/strings/search.jl
Line 346 in bb2aa52