Skip to content

Commit d40eeff

Browse files
author
Christopher Doris
committed
StaticStrings terminated by all nulls
1 parent 97972d3 commit d40eeff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/utils.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ module Utils
170170
end
171171

172172
function Base.String(x::StaticString{T,N}) where {T,N}
173-
i = findfirst(iszero, x.codeunits)
174-
j = i === nothing ? N : i - 1
175-
cs = T[x.codeunits[i] for i in 1:j]
173+
ts = x.codeunits
174+
n = N
175+
while n > 0 && iszero(ts[n])
176+
n -= 1
177+
end
178+
cs = T[ts[i] for i in 1:n]
176179
transcode(String, cs)
177180
end
178181

0 commit comments

Comments
 (0)