@@ -701,8 +701,9 @@ const Chrs = @static V6_COMPAT ? Union{Char,AbstractChar} : Chr
701
701
function repeat (ch:: CP , cnt:: Integer ) where {CP <: Chrs }
702
702
C = codepoint_cse (CP)
703
703
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)
706
707
end
707
708
708
709
(^ )(ch:: CP , cnt:: Integer ) where {CP <: Chrs } = repeat (ch, cnt)
849
850
_repeat (:: MultiCU , :: Type{UTF16CSE} , ch, cnt) =
850
851
ch <= 0xffff ? _repeat_chr (UInt16, ch, cnt) : _repeat_chr (UInt32, get_utf16_32 (ch), cnt)
851
852
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 ))
854
855
CU = codeunit (T)
855
856
@preserve str begin
856
857
len = ncodeunits (str)
@@ -871,6 +872,9 @@ function repeat(str::T, cnt::Integer) where {C<:CSE,T<:Str{C}}
871
872
end
872
873
Str (C, buf)
873
874
end
875
+
876
+ @inline repeat (str:: Str , cnt:: Integer ) = cnt == 1 ? str : _repeat_str (str, cnt)
877
+
874
878
(^ )(str:: T , cnt:: Integer ) where {T<: Str } = repeat (str, cnt)
875
879
876
880
# Definitions for C compatible strings, that don't allow embedded
0 commit comments