Skip to content

Commit

Permalink
Speeded up giv file parsing a bit by replacing atof with fast_double_…
Browse files Browse the repository at this point in the history
…parser.h

- See: https://github.com/lemire/fast_double_parser
- The speedup was less than I thought it would be :-(
  • Loading branch information
dov committed Mar 2, 2022
1 parent a506ef0 commit 99e78f3
Show file tree
Hide file tree
Showing 3 changed files with 1,319 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/WordBoundaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iostream>
#include <charconv>
#include "WordBoundaries.h"
#include "fast_double_parser.h"


using namespace std;
Expand Down Expand Up @@ -61,12 +62,11 @@ const char *WordBoundaries::GetRestAsString(int Index)
// Get a word as a floating point value.
double WordBoundaries::GetFloat(int Index)
{
const char *p = InspectionString;
const pair<int,int>& pp = (*this)[Index];
double d;

from_chars(InspectionString+pp.first, InspectionString+pp.second, d);

return d;
double x;
fast_double_parser::parse_number(p+pp.first, &x);
return x;
}

// Get a word as a floating point value.
Expand Down
Loading

0 comments on commit 99e78f3

Please sign in to comment.