PDA

View Full Version : QStringList optimize code block



pdoria
26th March 2012, 22:38
Hi guys,

Given two CSV strings (ptag and pdata)...
Want to join them in a single QStringList...

Can the following code block be optimized?



QString ptag = query.value(0).toString();
QString pdata = query.value(1).toString();

QStringList tag = ptag.split(",");
QStringList data = pdata.split(",");

for (int n=0; n < tag.size(); n++)
this->protocols << tag.at(n) + data.at(n);


Thx in advance!

Lykurg
27th March 2012, 06:28
++n is faster than n++, but the compiler will normally optimize that. Also
int size = tag.size();
for (int n = 0; n < size; ++n)could help. Have you compared the speed of at() and []? Further I do not see any possibilities to speed up that code.