r/learncpp • u/vgordievskiy • Mar 09 '21
How to improve it?
;
;
SResp
boost::optional<std::string>
int
How to improve this code?
8
Upvotes
r/learncpp • u/vgordievskiy • Mar 09 '21
;
;
SResp
boost::optional<std::string>
int
How to improve this code?
View all comments
Show parent comment
2
u/jedwardsol Mar 09 '21
It's not a good question.
You can do better by doing
but I doubt that that is what they're getting at.
You can make arguments that method X is faster than stringstream. Or you can optimise the loop since
valnever changes so it is pointless formatting it 100 times.But what's the point? In this program, there is a fixed output so all other work is unnecessary. And a different program will have different bottlenecks, so optimising that hypothetical program by analysing this one is useless.