@@ -935,29 +935,39 @@ repeat(ch::UTF32Chr, cnt::Integer) = _repeat(UTF32CSE, ch, cnt)
935
935
=#
936
936
937
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)
938
+ if cnt > 0
939
+ cu = ch% UInt8
940
+ buf, pnt = _allocate (UInt8, cnt)
941
+ _memset (pnt, cu, cnt)
942
+ if C == ASCIIChr || cu <= 0x7f
943
+ Str (ASCIICSE, buf)
944
+ elseif C == _LatinChr
945
+ Str (_LatinCSE, buf)
946
+ else
947
+ Str (LatinCSE, buf)
948
+ end
949
+ else
950
+ cnt == 0 ? empty_ascii : repeaterr (cnt)
951
+ end
944
952
end
945
953
946
954
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
950
- 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
954
- buf, pnt = _allocate (UInt16, cnt)
955
- cnt == 1 && set_codeunit! (pnt, ch% UInt16) : _aligned_set (pnt, ch% UInt16, cnt)
956
- Str (UCS2CSE, buf)
955
+ if cnt > 0
956
+ if ch% UInt32 <= 0xff
957
+ buf, pnt = _allocate (UInt8, cnt)
958
+ cnt == 1 ? set_codeunit! (pnt, ch% UInt8) : _memset (pnt, ch% UInt8, cnt)
959
+ ch% UInt8 <= 0x7f ? Str (ASCIICSE, buf) : Str (LatinCSE, buf)
960
+ elseif C == UCS2Chr || ch% UInt32 <= 0xffff
961
+ buf, pnt = _allocate (UInt16, cnt)
962
+ cnt == 1 ? set_codeunit! (pnt, ch% UInt16) : _aligned_set (pnt, ch% UInt16, cnt)
963
+ Str (UCS2CSE, buf)
964
+ else
965
+ buf, pnt = _allocate (UInt32, cnt)
966
+ cnt == 1 ? set_codeunit! (pnt, ch% UInt32) : _aligned_set (pnt, ch% UInt32, cnt)
967
+ Str (UTF32CSE, buf)
968
+ end
957
969
else
958
- buf, pnt = _allocate (UInt32, cnt)
959
- cnt == 1 && set_codeunit! (pnt, ch% UInt32) : _aligned_set (pnt, ch% UInt32, cnt)
960
- Str (UTF32CSE, buf)
970
+ cnt == 0 ? empty_ascii : repeaterr (cnt)
961
971
end
962
972
end
963
973
0 commit comments