@@ -910,57 +910,49 @@ end
910910
911911(^ )(ch:: CP , cnt:: Integer ) where {CP <: Chrs } = repeat (ch, cnt)
912912
913- #=
914- function _repeat(::Type{CS}, ch::C, cnt::Integer) where {CS<:CSE,C<:Union{ASCIIChr,LatinChr}}
915- cnt == 0 && return empty_str(CS)
916- cnt < 0 && repeaterr(cnt)
917- buf, pnt = _allocate(UInt8, cnt)
918- cnt == 1 ? set_codeunit!(pnt, ch%UInt8) : _memset(pnt, ch%UInt8, cnt)
919- Str(CS, buf)
920- end
921-
922- function _repeat(::Type{CS}, ch::C, cnt::Integer) where {CS<:CSE,C<:Union{UCS2Chr,UTF32Chr}}
923- cnt == 0 && return empty_str(CS)
924- cnt < 0 && repeaterr(cnt)
925- CU = codeunit(CS)
926- buf, pnt = _allocate(CU, cnt)
927- cnt == 1 ? set_codeunit!(pnt, ch%CU) : _aligned_set(pnt, ch%CU, cnt)
928- Str(CS, buf)
929- end
930-
931- repeat(ch::ASCIIChr, cnt::Integer) = _repeat(ASCIICSE, ch, cnt)
932- repeat(ch::LatinChr, cnt::Integer) = _repeat(LatinCSE, ch, cnt)
933- repeat(ch::UCS2Chr, cnt::Integer) = _repeat(UCS2CSE, ch, cnt)
934- repeat(ch::UTF32Chr, cnt::Integer) = _repeat(UTF32CSE, ch, cnt)
935- =#
936-
937- function repeat (ch:: C , cnt:: Integer ) where {C<: Union{ASCIIChr,LatinChr,_LatinChr} }
938- cnt == 0 && return empty_str (ASCIICSE)
939- cnt < 0 && repeaterr (cnt)
940- cu = ch% UInt8
941- buf, pnt = _allocate (UInt8, cnt)
942- _memset (pnt, cu, cnt)
943- Str ((C == ASCIIChr || cu <= 0x7f ) ? ASCIICSE : (C == _LatinChr ? _LatinCSE : LatinCSE), buf)
944- end
945-
946- function repeat (ch:: C , cnt:: Integer ) where {C<: Union{UCS2Chr,UTF32Chr} }
947- cnt == 0 && return empty_str (ASCIICSE)
948- cnt < 0 && repeaterr (cnt)
949- if ch% UInt32 <= 0xff
913+ function repeat (ch:: C , cnt:: Integer ) where {C<: Union{ASCIIChr,LatinChr} }
914+ if cnt > 0
915+ cu = ch% UInt8
950916 buf, pnt = _allocate (UInt8, cnt)
951- cnt == 1 && set_codeunit! (pnt, ch% UInt8) : _memset (pnt, ch% UInt8, cnt)
952- Str (ifelse (ch% UInt8 <= 0x7f , ASCIICSE, LatinCSE), buf)
953- elseif C == UCS2Chr || ch% UInt32 <= 0xffff
917+ _memset (pnt, cu, cnt)
918+ C == ASCIIChr ? Str (ASCIICSE, buf) : Str (LatinCSE, buf)
919+ else
920+ cnt < 0 ? repeaterr (cnt) : C == ASCIIStr ? empty_ascii : empty_latin
921+ end
922+ end
923+
924+ function repeat (ch:: _LatinChr , cnt:: Integer )
925+ if cnt > 0
926+ cu = ch% UInt8
927+ buf, pnt = _allocate (UInt8, cnt)
928+ _memset (pnt, cu, cnt)
929+ cu <= 0x7f ? Str (ASCIICSE, buf) : Str (_LatinCSE, buf)
930+ else
931+ cnt == 0 ? empty_ascii : repeaterr (cnt)
932+ end
933+ end
934+
935+ function repeat (ch:: UCS2Chr , cnt:: Integer )
936+ if cnt > 0
954937 buf, pnt = _allocate (UInt16, cnt)
955- cnt == 1 && set_codeunit! (pnt, ch% UInt16) : _aligned_set (pnt, ch% UInt16, cnt)
938+ cnt == 1 ? set_codeunit! (pnt, ch% UInt16) : _aligned_set (pnt, ch% UInt16, cnt)
956939 Str (UCS2CSE, buf)
957940 else
941+ cnt == 0 ? empty_ucs2 : repeaterr (cnt)
942+ end
943+ end
944+
945+ function repeat (ch:: UTF32Chr , cnt:: Integer )
946+ if cnt > 0
958947 buf, pnt = _allocate (UInt32, cnt)
959- cnt == 1 && set_codeunit! (pnt, ch% UInt32) : _aligned_set (pnt, ch% UInt32, cnt)
948+ cnt == 1 ? set_codeunit! (pnt, ch% UInt32) : _aligned_set (pnt, ch% UInt32, cnt)
960949 Str (UTF32CSE, buf)
950+ else
951+ cnt == 0 ? empty_utf32 : repeaterr (cnt)
961952 end
962953end
963954
955+
964956# Definitions for C compatible strings, that don't allow embedded
965957# '\0', and which are terminated by a '\0'
966958
0 commit comments