[–] CarloWood 6y ago ↗ I'd use std::memset and have something that works without needing a benchmark to detect obscure template quirks. [–] hikarudo 6y ago ↗ I agree. Why go through the extra loops? Keep it simple. [–] tipiak 6y ago ↗ std::memset only works for sequential and contiguous memory. std::fill works on pretty much anything that has std::begin() and std::end().As the conclusion of the article says I would use the idiomatic way first, then and only if I have performance issues, actually force it to memset.The only bad thing here is that, gcc only do the reasonable optimization on '-O3'.
[–] hikarudo 6y ago ↗ I agree. Why go through the extra loops? Keep it simple. [–] tipiak 6y ago ↗ std::memset only works for sequential and contiguous memory. std::fill works on pretty much anything that has std::begin() and std::end().As the conclusion of the article says I would use the idiomatic way first, then and only if I have performance issues, actually force it to memset.The only bad thing here is that, gcc only do the reasonable optimization on '-O3'.
[–] tipiak 6y ago ↗ std::memset only works for sequential and contiguous memory. std::fill works on pretty much anything that has std::begin() and std::end().As the conclusion of the article says I would use the idiomatic way first, then and only if I have performance issues, actually force it to memset.The only bad thing here is that, gcc only do the reasonable optimization on '-O3'.
[–] NablaSquaredG 6y ago ↗ Well, if it's optimised out at "-O3", I usually don't care. If you have some numerical code you can optimise further (even though you're using "-O3" or "-ffast-math"), things become interesting!
7 comments
[ 2.3 ms ] story [ 27.0 ms ] threadAs the conclusion of the article says I would use the idiomatic way first, then and only if I have performance issues, actually force it to memset.
The only bad thing here is that, gcc only do the reasonable optimization on '-O3'.