Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix equality for same-length comparisons with String #43

Merged
merged 2 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "ShortStrings"
uuid = "63221d1c-8677-4ff0-9126-0ff0817b4975"
authors = ["Dai ZJ <[email protected]>", "ScottPJones <[email protected]>",
"Lyndon White <[email protected]>"]
version = "0.3.4"
version = "0.3.5"

[deps]
BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1"
Expand Down
4 changes: 2 additions & 2 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ end
function ==(a::ShortString, b::String)
sz = sizeof(a)
sizeof(b) == sz || return false
sz == 0 || return true
sz == 0 && return true
val = _swapped_str(a)
@preserve b begin
pnt = reinterpret(Ptr{UInt}, pointer(b))
Expand All @@ -232,7 +232,7 @@ end
function ==(s::ShortString, b::SubString{String})
sz = sizeof(s)
sizeof(b) == sz || return false
sz == 0 || return true
sz == 0 && return true
val = _swapped_str(s)
@preserve s begin
pnt = pointer(b)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function basic_test(string_type, constructor, max_len)
@test str_maxlen == short_maxlen
@test short_maxlen == short_maxlen
@test short_maxlen != constructor("d"^max_len)
@test short_maxlen != string_type("d"^max_len)
@test short_maxlen != short_maxlen_m_1
@test short_maxlen_m_1 != short_maxlen
@test short_maxlen != str_maxlen_m_1
Expand Down