Open dimztimz opened 3 weeks ago
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.