faster double and date parsing
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "table.h"
|
||||
#include "csvreader.h"
|
||||
#include "ml_string.h"
|
||||
#include "fast_double_parser.h"
|
||||
|
||||
#include <charconv>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -138,11 +140,12 @@ void Table::create_row_from_vector(const std::vector<ColDefNode> &colDefs, const
|
||||
}
|
||||
|
||||
double Table::string_to_double(const std::string &s) {
|
||||
try {
|
||||
return std::stod(s);
|
||||
} catch (std::invalid_argument &e) {
|
||||
double result;
|
||||
const char * endptr = fast_double_parser::parse_number(s.c_str(), &result);
|
||||
if (endptr == nullptr) {
|
||||
throw Exception("error parsing as double: " + s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
long Table::string_to_long(const std::string &s) {
|
||||
|
||||
Reference in New Issue
Block a user