Skip to content

Commit af3cd59

Browse files
authored
eliminate copy for Unicode.normalize of substring (#38381)
eliminate copy for Unicode.normalize of substring
1 parent 9c498bf commit af3cd59

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

base/strings/unicode.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const UTF8PROC_STRIPMARK = (1<<13)
145145

146146
utf8proc_error(result) = error(unsafe_string(ccall(:utf8proc_errmsg, Cstring, (Cssize_t,), result)))
147147

148-
function utf8proc_map(str::String, options::Integer)
148+
function utf8proc_map(str::Union{String,SubString{String}}, options::Integer)
149149
nwords = ccall(:utf8proc_decompose, Int, (Ptr{UInt8}, Int, Ptr{UInt8}, Int, Cint),
150150
str, sizeof(str), C_NULL, 0, options)
151151
nwords < 0 && utf8proc_error(nwords)

stdlib/Unicode/test/runtests.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using Unicode: normalize, isassigned
66

77
@testset "string normalization" begin
88
# normalize (Unicode normalization etc.):
9-
@test normalize("\u006e\u0303", :NFC) == "\u00f1"
9+
@test normalize("\u006e\u0303", :NFC) == "\u00f1" == normalize(SubString("ab\u006e\u0303cd",3,4), :NFC)
1010
@test "\u006e\u0303" == normalize("\u00f1", :NFD)
1111
@test normalize("\ufb00", :NFC) != "ff"
1212
@test normalize("\ufb00", :NFKC) == "ff"

0 commit comments

Comments
 (0)