@@ -8,44 +8,44 @@ Licensed under MIT License, see LICENSE.md
88Inspired by / derived from code in Julia
99=#
1010
11- _lastindex (:: CodeUnitSingle , str) = (@_inline_meta (); ncodeunits (str))
11+ _lastindex (:: SingleCU , str) = (@_inline_meta (); ncodeunits (str))
1212
13- @propagate_inbounds function _getindex (:: CodeUnitSingle , T, str, pos:: Int )
13+ @propagate_inbounds function _getindex (:: SingleCU , T, str, pos:: Int )
1414 @_inline_meta ()
1515 @boundscheck checkbounds (str, pos)
1616 T (get_codeunit (pointer (str), pos))
1717end
1818
19- @propagate_inbounds function _next (:: CodeUnitSingle , T, str, pos)
19+ @propagate_inbounds function _next (:: SingleCU , T, str, pos)
2020 @_inline_meta ()
2121 @boundscheck 0 < pos <= ncodeunits (str) || boundserr (str, pos)
2222 T (get_codeunit (str, pos)), pos + 1
2323end
2424
25- _nextcpfun (:: CodeUnitSingle , :: Type{S} , pnt:: Ptr{T} ) where {S,T<: CodeUnitTypes } =
25+ _nextcpfun (:: SingleCU , :: Type{S} , pnt:: Ptr{T} ) where {S,T<: CodeUnitTypes } =
2626 get_codeunit (pnt), pnt + sizeof (T)
2727_nextcp (:: Type{T} , pnt) where {T} = _nextcpfun (CodePointStyle (T), T, pnt)
2828
29- @propagate_inbounds _getindex (:: CodeUnitMulti , T, str, pos:: Int ) =
30- first (_next (CodeUnitMulti (), T, str, pos))
29+ @propagate_inbounds _getindex (:: MultiCU , T, str, pos:: Int ) =
30+ first (_next (MultiCU (), T, str, pos))
3131
32- @inline _length (:: CodeUnitSingle , str) = ncodeunits (str)
32+ @inline _length (:: SingleCU , str) = ncodeunits (str)
3333
3434# Use more generic length check
3535@inline _length_check (str:: SubString{<:Str{C}} , cnt) where {C<: CSE } =
36- _length (CodeUnitMulti (), C, pointer (str), cnt)
36+ _length (MultiCU (), C, pointer (str), cnt)
3737
3838# Go directly to aligned length check
3939@inline _length_check (str:: Str{C} , cnt) where {C<: CSE } =
40- _length_al (CodeUnitMulti (), C, pointer (str), cnt)
40+ _length_al (MultiCU (), C, pointer (str), cnt)
4141
42- @inline _length (:: CodeUnitMulti , str:: MaybeSub{T} ) where {T<: Str } =
42+ @inline _length (:: MultiCU , str:: MaybeSub{T} ) where {T<: Str } =
4343 (cnt = ncodeunits (str); cnt < 2 ? Int (cnt > 0 ) : @preserve str _length_check (str, cnt))
4444
45- @inline _length (:: CodeUnitSingle , :: Type{<:CSE} , :: Ptr{<:CodeUnitTypes} , cnt:: Int ) = cnt
45+ @inline _length (:: SingleCU , :: Type{<:CSE} , :: Ptr{<:CodeUnitTypes} , cnt:: Int ) = cnt
4646
47- @inline _length (:: CodeUnitMulti , str:: Str{RawUTF8CSE} ) = length (str. data)
48- @inline _length (:: CodeUnitMulti , str:: Str{RawUTF8CSE} , i:: Int , j:: Int ) = length (str. data, i, j)
47+ @inline _length (:: MultiCU , str:: Str{RawUTF8CSE} ) = length (str. data)
48+ @inline _length (:: MultiCU , str:: Str{RawUTF8CSE} , i:: Int , j:: Int ) = length (str. data, i, j)
4949
5050@propagate_inbounds function _length (cs:: CodePointStyle , str, i:: Int , j:: Int )
5151 @boundscheck begin
@@ -58,7 +58,7 @@ _nextcp(::Type{T}, pnt) where {T} = _nextcpfun(CodePointStyle(T), T, pnt)
5858 @preserve str _length (cs, cse (str), bytoff (pointer (str), i - 1 ), cnt)
5959end
6060
61- @inline _thisind (:: CodeUnitSingle , str, len, pnt, pos) = Int (pos)
61+ @inline _thisind (:: SingleCU , str, len, pnt, pos) = Int (pos)
6262
6363@propagate_inbounds function _thisind (cs:: CS , str, pos) where {CS<: CodePointStyle }
6464 @_inline_meta ()
7171 @preserve str _thisind (cs, str, len, pointer (str), pos)
7272end
7373
74- @propagate_inbounds function _prevind (:: CodeUnitSingle , str, i)
74+ @propagate_inbounds function _prevind (:: SingleCU , str, i)
7575 @_inline_meta ()
7676 @boundscheck 0 < i <= ncodeunits (str)+ 1 || boundserr (str, i)
7777 Int (i) - 1
7878end
7979
80- @propagate_inbounds function _prevind (:: CodeUnitSingle , str, i, nchar)
80+ @propagate_inbounds function _prevind (:: SingleCU , str, i, nchar)
8181 @_inline_meta ()
8282 nchar < 0 && ncharerr (nchar)
8383 @boundscheck 0 < i <= ncodeunits (str)+ 1 || boundserr (str, i)
8484 max (Int (i) - nchar, 0 )
8585end
8686
87- @propagate_inbounds function _nextind (:: CodeUnitSingle , str, i)
87+ @propagate_inbounds function _nextind (:: SingleCU , str, i)
8888 @_inline_meta ()
8989 @boundscheck 0 <= i <= ncodeunits (str) || boundserr (str, i)
9090 Int (i) + 1
9191end
9292
93- @propagate_inbounds function _nextind (:: CodeUnitSingle , str, i, nchar)
93+ @propagate_inbounds function _nextind (:: SingleCU , str, i, nchar)
9494 @_inline_meta ()
9595 nchar < 0 && ncharerr (nchar)
9696 @boundscheck 0 <= i <= ncodeunits (str) || boundserr (str, i)
@@ -149,20 +149,20 @@ end
149149 _isvalid_char_pos (CodePointStyle (T), cse (T), str, i)
150150end
151151
152- _isvalid_char_pos (:: CodeUnitSingle , C, str, i) = true
152+ _isvalid_char_pos (:: SingleCU , C, str, i) = true
153153
154- @propagate_inbounds function _collectstr (:: CodeUnitMulti , :: Type{S} ,
154+ @propagate_inbounds function _collectstr (:: MultiCU , :: Type{S} ,
155155 str:: MaybeSub{T} ) where {S,T<: Str }
156- len = _length (CodeUnitMulti (), str)
156+ len = _length (MultiCU (), str)
157157 vec = create_vector (S, len)
158158 pos = 1
159159 @inbounds for i = 1 : len
160- vec[i], pos = _next (CodeUnitMulti (), S, str, pos)
160+ vec[i], pos = _next (MultiCU (), S, str, pos)
161161 end
162162 vec
163163end
164164
165- @propagate_inbounds function _collectstr (:: CodeUnitSingle , :: Type{S} ,
165+ @propagate_inbounds function _collectstr (:: SingleCU , :: Type{S} ,
166166 str:: MaybeSub{T} ) where {S,T<: Str }
167167 len = ncodeunits (str)
168168 vec = create_vector (S, len)
@@ -219,7 +219,7 @@ function _convert(::Type{C}, ch::T) where {C<:CSE,T<:CodeUnitTypes}
219219 Str (C, buf)
220220end
221221
222- # Todo: These should be made more generic, work for all CodeUnitSingle types
222+ # Todo: These should be made more generic, work for all SingleCU types
223223
224224convert (:: Type{<:Str{ASCIICSE}} , ch:: Unsigned ) =
225225 is_ascii (ch) ? _convert (ASCIICSE, ch% UInt8) : unierror (UTF_ERR_INVALID_ASCII, 0 , ch)
@@ -258,7 +258,7 @@ unsafe_convert(::Type{Ptr{Text4Chr}}, str::MaybeSub{<:Str{<:Quad_CSEs}}) =
258258unsafe_convert (:: Type{Ptr{Cvoid}} , s:: MaybeSub{<:Str{C}} ) where {C} =
259259 reinterpret (Ptr{Cvoid}, unsafe_convert (Ptr{codeunit (C)}, s))
260260
261- function _reverse (:: CodeUnitSingle , :: Type{C} , len, str:: Str{C} ) where {C<: CSE }
261+ function _reverse (:: SingleCU , :: Type{C} , len, str:: Str{C} ) where {C<: CSE }
262262 len < 2 && return str
263263 @preserve str begin
264264 pnt = pointer (str)
@@ -273,9 +273,9 @@ function _reverse(::CodeUnitSingle, ::Type{C}, len, str::Str{C}) where {C<:CSE}
273273 end
274274end
275275
276- function _reverse (:: CodeUnitMulti , :: Type{C} , len, str) where {C<: CSE }
276+ function _reverse (:: MultiCU , :: Type{C} , len, str) where {C<: CSE }
277277 @inbounds ((t = nextind (str, 0 )) > len || nextind (str, t) > len) && return str
278- @preserve str _reverse (CodeUnitMulti (), C, len, pointer (str))
278+ @preserve str _reverse (MultiCU (), C, len, pointer (str))
279279end
280280
281281reverse (str:: MaybeSub{T} ) where {C<: CSE ,T<: Str{C} } =
0 commit comments