Optimization of a Qt QByteArray conversion I wrote a function to convert a hexadecimal string representation (like 0x00) of some binary data to the data itself.

How can I improve this code?

QByteArray restoreData(const QByteArray &amp;data, const QString prepender = "x")
{
    QByteArray restoredData = data;

    return QByteArray::fromHex(restoredData.replace(prepender, ""));
}
Try to avoid deep copying of source array, this can be achived with right method:

QByteArray restoreData(const QByteArray &amp;data, char prepender = 'x')
{
    return QByteArray::fromHex(data.right(data.size() - data.indexOf(prepender) - 1);
}