View difference between Paste ID: VAbdBBuA and R6gH2LCQ
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-
    int indexNL = -NEWLINE.count();
8+
    QStringList lines = QString(str).split(NEWLINE);
9-
    while(indexNL != -1) {
9+
    for(const auto &s : lines) {
10-
        indexNL += NEWLINE.count();
10+
11-
        int currStart = indexNL;
11+
        QString key = s.left(cutAt);
12-
        indexNL = str.indexOf(NEWLINE, indexNL+1);
12+
        QString value = s.right(s.length() - cutAt - SEP.length());
13
        //qDebug() << "KEY: "<< key << " VALUE: "<<value;
14-
        QByteArray s = str.mid(currStart, indexNL - currStart);
14+
15-
        //qDebug() << s;
15+
16
}
17-
        if(cutAt == -1)
17+
18-
            cutAt = s.count() -1;
18+
Elapsed time:	 552 ms
19
One cycle:	 1.840000 ms
20-
        QByteArray key = s.left(cutAt);
20+
Create item:	 0.008519 ms
21-
        QByteArray value = s.right(s.length() - cutAt - SEP.length());
21+
22-
        //qDebug("KEY: %15s\tVALUE: %15s\tCUTAT: %d", key.constData(), value.constData(), cutAt);
22+