Hacker News new | ask | show | jobs
by zombot 471 days ago
> it++

Should be ++it. Post-increment is generally more expensive, especially when you don't know the exact type you're applying it to.

1 comments

I'd normally agree with you, but in this case this function is meant to be used for vectorizable input so it doesn't really matter since it's using a random-access iterator, otherwise you should go with the usual std::count_if().

Then again, it doesn't hurt to be pedantic.

It's not about being pedantic, it's about building the right habits. Building a habit of using x++ instead of ++x is suboptimal.