|
1 | 1 | module InlineStrings
|
2 | 2 |
|
3 |
| -import Base: == |
4 |
| - |
5 | 3 | export InlineString, InlineStringType, inlinestrings
|
6 | 4 | export @inline_str
|
7 | 5 |
|
@@ -290,14 +288,16 @@ macro inline_str(ex)
|
290 | 288 | end
|
291 | 289 |
|
292 | 290 |
|
293 |
| -(==)(x::T, y::T) where {T <: InlineString} = Base.eq_int(x, y) |
294 |
| -function ==(x::String, y::T) where {T <: InlineString} |
| 291 | +Base.:(==)(x::T, y::T) where {T <: InlineString} = Base.eq_int(x, y) |
| 292 | +function Base.:(==)(x::String, y::T) where {T <: InlineString} |
295 | 293 | sizeof(x) == sizeof(y) || return false
|
296 | 294 | ref = Ref{T}(_bswap(y))
|
297 |
| - return ccall(:memcmp, Cint, (Ptr{UInt8}, Ref{T}, Csize_t), |
298 |
| - pointer(x), ref, sizeof(x)) == 0 |
| 295 | + GC.@preserve x begin |
| 296 | + return ccall(:memcmp, Cint, (Ptr{UInt8}, Ref{T}, Csize_t), |
| 297 | + pointer(x), ref, sizeof(x)) == 0 |
| 298 | + end |
299 | 299 | end
|
300 |
| -==(y::InlineString, x::String) = x == y |
| 300 | +Base.:(==)(y::InlineString, x::String) = x == y |
301 | 301 |
|
302 | 302 | Base.cmp(a::T, b::T) where {T <: InlineString} =
|
303 | 303 | Base.eq_int(a, b) ? 0 : Base.ult_int(a, b) ? -1 : 1
|
|
0 commit comments