[Qt-creator] QtEndian implementation question
Spam Box
spiceycannedham at gmail.com
Fri Jun 26 01:19:55 CEST 2015
Hello,
I was recently working on some code where I wanted to use the QtEndian
stuff. I noticed that the functions that take const uchar* seem to do some
unnecessary operations.
For example this function is defined on a little endian target.
template <> inline quint32 qFromLittleEndian<quint32>(const uchar *src)
{
return 0
| src[0]
| src[1] * quint32(0x00000100)
| src[2] * quint32(0x00010000)
| src[3] * quint32(0x01000000);
}
The memory being pointed at is already in little endian order. Why not just
reinterpret_cast instead of performing several operations? Wouldn't that be
faster? What am I missing?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150625/709678fb/attachment.html>
More information about the Qt-creator
mailing list