SHOW:
|
|
- or go back to the newest paste.
| 1 | const QByteArray SEP = ": "; | |
| 2 | const QByteArray NEWLINE = "\r\n"; | |
| 3 | ||
| 4 | QMap<QString, QString> m_Values; | |
| 5 | ||
| 6 | void QAmiPropertyMap::convertStr(const QByteArray &str) | |
| 7 | {
| |
| 8 | - | QStringList lines = QString(str).split(NEWLINE); |
| 8 | + | int indexNL = -NEWLINE.count(); |
| 9 | - | for(const auto &s : lines) {
|
| 9 | + | while(indexNL != -1) {
|
| 10 | indexNL += NEWLINE.count(); | |
| 11 | - | QByteArray key = s.left(cutAt).toLocal8Bit(); |
| 11 | + | int currStart = indexNL; |
| 12 | - | QByteArray value = s.right(s.length() - cutAt - SEP.length()).toLocal8Bit(); |
| 12 | + | indexNL = str.indexOf(NEWLINE, indexNL+1); |
| 13 | ||
| 14 | QByteArray s = str.mid(currStart, indexNL - currStart); | |
| 15 | //qDebug() << s; | |
| 16 | int cutAt = s.indexOf(SEP); | |
| 17 | - | Elapsed time: 1468 ms |
| 17 | + | if(cutAt == -1) |
| 18 | - | One cycle: 4.893333 ms |
| 18 | + | cutAt = s.count() -1; |
| 19 | - | Create item: 0.022654 ms |
| 19 | + | |
| 20 | QByteArray key = s.left(cutAt); | |
| 21 | QByteArray value = s.right(s.length() - cutAt - SEP.length()); | |
| 22 | //qDebug("KEY: %15s\tVALUE: %15s\tCUTAT: %d", key.constData(), value.constData(), cutAt);
| |
| 23 | m_Values.insert(key, value); | |
| 24 | } | |
| 25 | } | |
| 26 | ||
| 27 | Elapsed time: 519 ms | |
| 28 | One cycle: 1.730000 ms | |
| 29 | Create item: 0.008009 ms | |
| 30 | Items: 216 | |
| 31 | Create count (300x216): 64800 |