Skip to content

Commit

Permalink
Merge pull request #43 from iamed2/ed/fix-equality
Browse files Browse the repository at this point in the history
Fix equality for same-length comparisons with String
  • Loading branch information
oxinabox authored Feb 11, 2021
2 parents 319ee78 + 8010bf9 commit f55c3ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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

2 comments on commit f55c3ae

@oxinabox
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29897

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.5 -m "<description of version>" f55c3aeb4145fb093c81c8c14451afae3f5f3847
git push origin v0.3.5

Please sign in to comment.