No the two are not equal. If bytesReceived is empty then the first option merely points at the existing buffer and the second immediately makes a copy of the buffer into its own storage. If bytesReceived is not empty at the time of the append() call then both copy the data out of the existing buffer into their own storage.
That depends entirely on what you intend to do with the bytesReceived QByteArray. You don't tell us, but in your code it is non-const and therefore we assume it will be modified. In that case there will be a deep copy of the original data anyway.Which would be the smartest way of handling this in a embedded development situation,
Bookmarks