Skip to content

Commit

Permalink
Fixed: use unused variable in String#<=>
Browse files Browse the repository at this point in the history
Because all String end with a `\0` this isn't a real problem, as memcmp
would stop at that `\0` so there's no unsafe memory access, but this
change is still more correct.
  • Loading branch information
asterite committed Jan 20, 2017
1 parent 42e2a52 commit 47a3002
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/string.cr
Expand Up @@ -2038,7 +2038,7 @@ class String
return 0 if same?(other)
min_bytesize = Math.min(bytesize, other.bytesize)

cmp = to_unsafe.memcmp(other.to_unsafe, bytesize)
cmp = to_unsafe.memcmp(other.to_unsafe, min_bytesize)
cmp == 0 ? (bytesize <=> other.bytesize) : cmp.sign
end

Expand Down

0 comments on commit 47a3002

Please sign in to comment.