Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, July 2007
Performance: QByteArray vs. QString


Message 1 in thread

Hi all,

I'm developing an application which repeatedly takes data from a socket,
performs a moderate amount of parsing on it, and passes it up to the GUI.
The QTcpSocket returns data in the form of a QByteArray, and the GUI classes
usually expect QStrings - thus, somewhere along the line, I've got to make
that conversion happen.

The parsing is of a text-based protocol and involves a lot of comparisons,
chopping and such - my question is, is there any significant performance
difference between doing this work on a QByteArray and a QString? QByteArray
"seems" more lightweight, and thus that's what the parser uses now, but it'd
make my design a little more streamlined to convert to QString as early as
possible (once the data comes out of the socket, say) and I'm not sure if
there are any tangible benefits to using one or the other here. It's not a
particularly memory or performance-critical app.

Thanks,

Evan DeMond