From 0b54ded93b693189c8efe25ac0bc4efbce4e0a06 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 6 Jul 2023 03:58:09 -0400 Subject: [PATCH] avoid potential type-instability in _replace_(str, ...) (#50424) --- base/strings/util.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/strings/util.jl b/base/strings/util.jl index c818d723d688f..c77d45255a735 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -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)))