Closed BillyONeal closed 8 years ago
Thank you for the PR.
Can the issue be solved in other ways? For example, can you make the original code run faster by caching the results of s.end()
and *i
into local variables?
I am not generally against the idea of making a debug build run faster, but if that is the case, would like to see a PR that guarantees (or is reasonable to expect) that the performance of the debug build on other platforms do not get sacrificed.
relates to #84
What's the difference for release mode? Debug doesn't count at all.
@kazuho
Yes, the majority of the win here is by not calling end() n times in the loop. std::for_each
can still do better than the handwritten loop because it can do the range check once, and then unwrap the iterators to raw pointers before iterating.
@AndiDog
I didn't observe any changes in release mode perf with this change.
@BillyONeal
std::for_each
can still do better than the handwritten loop because it can do the range check once, and then unwrap the iterators to raw pointers before iterating.
That's a good point. Merged to master.
FWIW, the difference between debug and release builds in this case was two orders of magnitude for some workloads - which was making debug builds outright unusable.
Results in 2x debug mode performance improvement for MSVC++, /Od /RTC1.