This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]