Skip to content
Snippets Groups Projects
Commit 726735c6 authored by Tom Fischer's avatar Tom Fischer Committed by Dmitri Naumov
Browse files

[GL/IO] Don't use stringstream in readCoordinates.

This saves almost 40% of run time.
parent 8f737db3
No related branches found
No related tags found
No related merge requests found
......@@ -249,10 +249,16 @@ std::optional<std::array<double, 3>> readCoordinates(std::istream& in)
std::string line("");
if (std::getline(in, line))
{
std::stringstream str_stream(line);
std::array<double, 3> coords;
str_stream >> coords[0] >> coords[1] >> coords[2];
return std::make_optional(coords);
if (std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0], &coords[1],
&coords[2]) == 3)
{
return coords;
}
else
{
OGS_FATAL("Could not parse coordinates in readCoordinates().");
}
}
return std::nullopt;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment