Skip to content

Commit

Permalink
Reduce comparisons when parsing numbers
Browse files Browse the repository at this point in the history
Before this commit, we would try to scan for a float, then if that
failed, scan for an integer.  But floats and integers have many bytes in
common, so we would end up scanning the same bytes multiple times.

This patch combines integer and float scanning machines so that we only
have to scan bytes once.  If the machine finds "float parts", then it
executes the "isFloat" transition in the machine, which sets a boolean
letting us know that the parser found a float.

If we didn't find a float, but we did match, then we know it's an int.
  • Loading branch information
tenderlove authored and byroot committed Nov 7, 2024
1 parent 1ecf7b4 commit 0c0e093
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 265 deletions.
Loading

0 comments on commit 0c0e093

Please # to comment.