This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
stringstream slowness
- From: Radu Grigore <radugrigore at gmail dot com>
- To: libstdc++ at sources dot redhat dot com
- Date: Tue, 22 Jun 2004 11:22:38 +0300
- Subject: stringstream slowness
A program like the following works about 3 times faster when compiled
with VS7.1, compared to gcc3.3.1. The optimizations are turned on (-O2
for gcc and "release" mode for VS).
#include <sstream>
using namespace std;
void f(vector<string> v)
{
for (int i = 0; i < int(v.size()); ++i)
{
istringstream iss(v[i]);
int a, b, c, d, e;
iss >> a >> b >> c >> d;
/* do something with a, b, c, d, e */
}
}
int main()
{
string v[] = {"1 2 3 4 5", "101 102 200 203 205"
/* add lots of others strings like these */ };
f(vector<string>(v, v + sizeof(v)/sizeof(v[0])));
}
PS: I am not subscribed to the list