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

Optimize String#to_u methods for the case of a negative number #7446

Merged
merged 6 commits into from
May 21, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make to_u64_info a method again
  • Loading branch information
r00ster authored Mar 1, 2019
commit b015d26e68413bcae957b5960807f80e15062f06
8 changes: 4 additions & 4 deletions src/string.cr
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class String
end
end

private macro to_u64_info(base, whitespace, underscore, prefix, strict, unsigned)
private def to_u64_info(base, whitespace, underscore, prefix, strict, unsigned)
raise ArgumentError.new("Invalid base #{base}") unless 2 <= base <= 36 || base == 62

ptr = to_unsafe
Expand All @@ -526,9 +526,9 @@ class String
# Check + and -
case ptr.value.unsafe_chr
when '-'
{% if unsigned %}
return yield
{% end %}
if unsigned
return ToU64Info.new 0, true, true
end
negative = true
ptr += 1
when '+'
Expand Down