You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My comments are mostly for the C++ proposal P1729. In the first revision the API used output parameters, similar to scanf and iostreams, but in the second revision it was changed to use return value. Now, the newer API might be more ergonomic (arguable), but it can be less performant, especially when reading strings.
Consider the following example:
std::string key;
int value;
for (...) {
std::scan(some_input, "{} = {}", key, value);
}
versus
for (...) {
auto result = std::scan<std::string, int>(some_input, "{} = {}")
}
The first example is more performant because it will reuse the same std::string object and it will avoid unnecesarry allocations. In the second example the std::string object will be constructed and destructed in each loop iteration, potentially allocating in each iteration. SSO saves something, but in the first example we save much more unnecessary allocations.
The text was updated successfully, but these errors were encountered:
I agree w/ this comment. IMO the v1 API was simpler to use, easier to understand, and easier to see how the format string tied to values. Converting our code to the new version has resulting in much longer and more confusing parse statements.
My comments are mostly for the C++ proposal P1729. In the first revision the API used output parameters, similar to
scanf
andiostreams
, but in the second revision it was changed to use return value. Now, the newer API might be more ergonomic (arguable), but it can be less performant, especially when reading strings.Consider the following example:
versus
The first example is more performant because it will reuse the same
std::string
object and it will avoid unnecesarry allocations. In the second example thestd::string
object will be constructed and destructed in each loop iteration, potentially allocating in each iteration. SSO saves something, but in the first example we save much more unnecessary allocations.The text was updated successfully, but these errors were encountered: