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

Improve String.toFloat and String.toInt #817

Closed
wants to merge 9 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@evancz
Member

evancz commented Jan 20, 2017

This should allow each parser to accept a broader range of inputs and parse them more quickly.

For example, toFloat can now handle scientific notation like 1e40, and toInt can handle hexadecimal like 0xBEEF.

This change relies on the fact that +str and Number(str) do the same thing, and that Number is more restrictive in parsing than parseInt and parseFloat. This is based on information from this and this.

I believe it will be faster, but I have not confirmed this.

Remaining Tasks

  • Confirm that this works with strictly larger range of numbers.
  • Actually race the new and old implementations against each other to compare speed.
  • Attempt to make it crash.
Improve String.toFloat and String.toInt
This change should allow each parser to accept a broader range of inputs. For example, `toFloat` can now handle scientific notation like `1e40`, and `toInt` can handle hexadecimal like `0xBEEF`.

I suspect this approach is also faster, but I would love confirmation of this!
@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Jan 20, 2017

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Jan 20, 2017

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz added some commits Jan 20, 2017

Properly check for [eE] for exponents
[eE] is allowed in hex numbers, but not in anything else.
@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 20, 2017

Member

Just a heads up, I'm working on the perf part / fixing some errors.

Member

evancz commented Jan 20, 2017

Just a heads up, I'm working on the perf part / fixing some errors.

@evancz evancz closed this Jan 20, 2017

@evancz evancz deleted the evancz-patch-1 branch Jan 20, 2017

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz
Member

evancz commented Jan 20, 2017

Okay, this is superseded by https://github.com/elm-lang/core/pull/818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment