Quote:Original post by KestQuote:Flip a coin then. They're never going to be exactly the same in terms of effort and readability, so the answer doesn't matter [lol].
You're saying one or more of my examples were difficult in some way to type or understand?
Difficult? No. Comparatively slower? Yes.
#1 I grok intuitively.
#2 I can quickly reason that third ends up being the sum of first and second, but it's still a minor distraction from the problem at hand.
#3 Would cause me to look up the function implementation of "AsSum". "As____" is not a C++ idiom, and the phrase would not appear in any english sentence for the actual effect that I'd ever construct, leaving me less than confident that my educated guess as to what it did (assuming I even had one) was on the mark. I would then rename the function "AssignToSumOf", and try to remember what I was working on before being derailed into sanity checking.
Quote:Original post by Kest
That's actually useful information. But several helpful posters beat you to it while you were micro-optimizing my usage of time.
Except I explicitly mentioned return value optimization (RVO -- maybe you just didn't make the connection?) in the very first reply to this topic, and stated that this would cause that version of operator+ to perform on par with the += version within the listed constraints. I guess I beat myself?
And micro optimizing your time usage would be where I simply shat out the answer "no." to the original question, however inaccurate, and we moved on. Instead, I am (attempting to) steer not just you, but anyone else who might be taking advice from this thread, away from the large time sink that we see here on gdnet time and time again of newbies sinking their time into the question of "which is faster of these two int-adding methods or similarly trivial operation which end up compiling identically in 99.99% of cases and isn't going to be the bottleneck" instead of, say, actually learning programming, learning big-O notation, or learning how to write a search that doesn't operate in O(n3).
If that truely falls into your conception of micro-optimizing your time, well, I'd invite you to give an example of something that would qualify as a macro optimization. I'm more than willing to better optimize my time spent optimizing the time spent by others spent optimizing (or, hell, performing other tasks as well [lol])