Skip to content

Commit

Permalink
performance tweak in reverse(::String) (#26300)
Browse files Browse the repository at this point in the history
No reason not to pass a `sizehint` in this function since we know the exact number of bytes required.
  • Loading branch information
stevengj authored and JeffBezanson committed Mar 3, 2018
1 parent ce26ed0 commit 05ff71f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/strings/substring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ julia> join(reverse(collect(graphemes("ax̂e")))) # reverses graphemes
```
"""
function reverse(s::Union{String,SubString{String}})::String
sprint() do io
sprint(sizehint=sizeof(s)) do io
i, j = firstindex(s), lastindex(s)
while i j
c, j = s[j], prevind(s, j)
Expand Down

2 comments on commit 05ff71f

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.