Added fast_float library as a replacement for std::from_chars and strtod.

This commit is contained in:
Lukáš Hejl 2021-09-09 15:25:14 +02:00
parent e3ac2a9e45
commit ad65366ac7
3 changed files with 2454 additions and 10 deletions

2449
src/fast_float/fast_float.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/nowide/fstream.hpp>
#include <charconv>
#include <fstream>
#include <iostream>
#include <iomanip>
@ -10,6 +9,7 @@
#include "LocalesUtils.hpp"
#include <Shiny/Shiny.h>
#include <fast_float/fast_float.h>
namespace Slic3r {
@ -71,16 +71,9 @@ const char* GCodeReader::parse_line_internal(const char *ptr, const char *end, G
}
if (axis != NUM_AXES_WITH_UNKNOWN) {
// Try to parse the numeric value.
#ifdef WIN32
double v;
auto [pend, ec] = std::from_chars(++ c, end, v);
auto [pend, ec] = fast_float::from_chars(++ c, end, v);
if (pend != c && is_end_of_word(*pend)) {
#else
// The older version of GCC and Clang support std::from_chars just for integers, so strtod we used it instead.
char *pend = nullptr;
double v = strtod(++ c, &pend);
if (pend != nullptr && is_end_of_word(*pend)) {
#endif
// The axis value has been parsed correctly.
if (axis != UNKNOWN_AXIS)
gline.m_axis[int(axis)] = float(v);

View File

@ -122,7 +122,9 @@ void CopyrightsDialog::fill_entries()
{ "AppImage packaging for Linux using AppImageKit"
, "2004-2019 Simon Peter and contributors" , "https://appimage.org/" },
{ "lib_fts"
, "Forrest Smith" , "https://www.forrestthewoods.com/" }
, "Forrest Smith" , "https://www.forrestthewoods.com/" },
{ "fast_float"
, "Daniel Lemire, João Paulo Magalhaes and contributors", "https://github.com/fastfloat/fast_float" }
};
}