[PATCH] Exploit move semantics in std::accumulate.
Eelis van der Weegen
eelis@eelis.net
Sat Jan 8 17:30:00 GMT 2011
The attached simple patch reduces the runtime of the following program
from 1.4 seconds to 0.005 seconds on my machine:
#include <iostream>
#include <string>
#include <numeric>
#include <vector>
int main()
{
std::vector<std::string> v;
for(int i = 0; i != 20000; ++i)
v.push_back(std::string(50, 'a'+(i%10)));
std::cout << std::accumulate(v.begin(), v.end(),
std::string()).size() << '\n';
}
Regards,
Eelis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Exploit-move-semantics-in-std-accumulate.patch
Type: text/x-patch
Size: 1137 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20110108/bf16617b/attachment.bin>
More information about the Libstdc++
mailing list