Skip to content

Commit f7269c5

Browse files
committed
no need to clear last byte when passing to C anymore (always null)
1 parent c51e12c commit f7269c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/InlineStrings.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ function Base.Symbol(x::T) where {T <: InlineString}
141141
end
142142

143143
Base.cconvert(::Type{Ptr{UInt8}}, x::T) where {T <: InlineString} =
144-
Ref{T}(_bswap(clear_n_bytes(x, 1)))
144+
Ref{T}(_bswap(x))
145145
Base.cconvert(::Type{Ptr{Int8}}, x::T) where {T <: InlineString} =
146-
Ref{T}(_bswap(clear_n_bytes(x, 1)))
146+
Ref{T}(_bswap(x))
147147
function Base.cconvert(::Type{Cstring}, x::T) where {T <: InlineString}
148-
ref = Ref{T}(_bswap(clear_n_bytes(x, 1)))
148+
ref = Ref{T}(_bswap(x))
149149
Base.containsnul(Ptr{Int8}(pointer_from_objref(ref)), sizeof(x)) &&
150150
throw(ArgumentError("embedded NULs are not allowed in C strings: $x"))
151151
return ref
@@ -177,7 +177,7 @@ end
177177

178178
# add a codeunit to end of string method
179179
function addcodeunit(x::T, b::UInt8) where {T <: InlineString}
180-
len = ncodeunits(x) % UInt8
180+
len = Base.trunc_int(UInt8, ncodeunits(x))
181181
sz = Base.trunc_int(UInt8, sizeof(T))
182182
shf = Base.zext_int(Int16, max(0x01, sz - len - 0x01)) << 3
183183
x = Base.or_int(x, Base.shl_int(Base.zext_int(T, b), shf))

0 commit comments

Comments
 (0)