Skip to content

Commit

Permalink
avoid potential type-instability in _replace_(str, ...) (#50424)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored Jul 6, 2023
1 parent 2360140 commit 0b54ded
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,11 @@ end

# note: leave str untyped here to make it easier for packages like StringViews to hook in
function _replace_(str, pat_repl::NTuple{N, Pair}, count::Int) where N
count == 0 && return str
count == 0 && return String(str)
e1, patterns, replaces, rs, notfound = _replace_init(str, pat_repl, count)
if notfound
foreach(_free_pat_replacer, patterns)
return str
return String(str)
end
out = IOBuffer(sizehint=floor(Int, 1.2sizeof(str)))
return String(take!(_replace_finish(out, str, count, e1, patterns, replaces, rs)))
Expand Down

0 comments on commit 0b54ded

Please sign in to comment.