Chaser

Untitled

Aug 7th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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();
  9.     while(indexNL != -1) {
  10.         indexNL += NEWLINE.count();
  11.         int currStart = indexNL;
  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.         if(cutAt == -1)
  18.             cutAt = s.count() -1;
  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
Advertisement
Add Comment
Please, Sign In to add comment