@@ -701,8 +701,9 @@ const Chrs = @static V6_COMPAT ? Union{Char,AbstractChar} : Chr
701701function repeat (ch:: CP , cnt:: Integer ) where {CP <: Chrs }
702702 C = codepoint_cse (CP)
703703 cnt > 1 && return Str (C, _repeat (EncodingStyle (C), C, codepoint (ch), cnt))
704- cnt < 0 && repeaterr (cnt)
705- cnt == 0 ? empty_str (C) : _convert (C, codepoint (ch))
704+ cnt == 1 && return _convert (C, codepoint (ch))
705+ cnt == 0 && return empty_str (C)
706+ repeaterr (cnt)
706707end
707708
708709(^ )(ch:: CP , cnt:: Integer ) where {CP <: Chrs } = repeat (ch, cnt)
849850_repeat (:: MultiCU , :: Type{UTF16CSE} , ch, cnt) =
850851 ch <= 0xffff ? _repeat_chr (UInt16, ch, cnt) : _repeat_chr (UInt32, get_utf16_32 (ch), cnt)
851852
852- function repeat (str:: T , cnt:: Integer ) where {C<: CSE ,T<: Str{C} }
853- cnt < 2 && return cnt == 1 ? str : (cnt == 0 ? empty_str (C ) : repeaterr (cnt ))
853+ function _repeat_str (str:: T , cnt) where {C<: CSE ,T<: Str{C} }
854+ cnt <= 0 && (cnt < 0 ? repeaterr (cnt ) : return empty_str (C ))
854855 CU = codeunit (T)
855856 @preserve str begin
856857 len = ncodeunits (str)
@@ -871,6 +872,9 @@ function repeat(str::T, cnt::Integer) where {C<:CSE,T<:Str{C}}
871872 end
872873 Str (C, buf)
873874end
875+
876+ @inline repeat (str:: Str , cnt:: Integer ) = cnt == 1 ? str : _repeat_str (str, cnt)
877+
874878(^ )(str:: T , cnt:: Integer ) where {T<: Str } = repeat (str, cnt)
875879
876880# Definitions for C compatible strings, that don't allow embedded
0 commit comments