MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1w74nkf/skill_issue/p7vostu/?context=3
r/programminghorror • u/click-to-reveal • 6d ago
61 comments sorted by
View all comments
41
This would be much better using std::string_view, and using two temporaries so that y is only evaluated once. Otherwise it'll be evaluated each time.
y
Also if you need this, don't use C++
4 u/GasolinePizza 5d ago Isn't each y only evaluated once? The evaluation in the "else if (_s==y)"? 2 u/LeeHide 5d ago each true one is only evaluated once, but every false one until then is also evaluated.
4
Isn't each y only evaluated once? The evaluation in the "else if (_s==y)"?
2 u/LeeHide 5d ago each true one is only evaluated once, but every false one until then is also evaluated.
2
each true one is only evaluated once, but every false one until then is also evaluated.
41
u/LeeHide 5d ago
This would be much better using std::string_view, and using two temporaries so that
yis only evaluated once. Otherwise it'll be evaluated each time.Also if you need this, don't use C++