mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Some micro-optimizatoins and code cleanup
This commit is contained in:
parent
25939cfa62
commit
3b16f37e66
@ -50,18 +50,13 @@ bool BitStream4::read(int bits, quint32 &val)
|
||||
return true;
|
||||
}
|
||||
|
||||
quint32 old = 0;
|
||||
if (_used < 32) {
|
||||
old = (_data << _used) >> (32 - bits);
|
||||
bits = (bits - 32) + _used;
|
||||
}
|
||||
_used = bits;
|
||||
|
||||
quint32 bytes = qMin(_length, (quint32)4);
|
||||
quint32 old = (_used < 32) ? (_data << _used) >> (32 - bits) : 0;
|
||||
quint32 bytes = qMin(_length, 4U);
|
||||
|
||||
if (!_file.readVUInt32SW(_hdl, bytes, _data))
|
||||
return false;
|
||||
|
||||
_used -= 32 - bits;
|
||||
_length -= bytes;
|
||||
_unused = (4 - bytes) * 8;
|
||||
_data <<= _unused;
|
||||
|
@ -69,20 +69,6 @@ bool SubFile::readVUInt32(Handle &hdl, quint32 &val) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SubFile::readVUInt32SW(Handle &hdl, quint32 bytes, quint32 &val) const
|
||||
{
|
||||
quint8 b;
|
||||
|
||||
val = 0;
|
||||
for (quint32 i = bytes; i; i--) {
|
||||
if (!readByte(hdl, b))
|
||||
return false;
|
||||
val |= ((quint32)b) << ((i-1) * 8);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SubFile::readVBitfield32(Handle &hdl, quint32 &bitfield) const
|
||||
{
|
||||
quint8 bits;
|
||||
|
@ -97,8 +97,21 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readVUInt32SW(Handle &hdl, quint32 bytes, quint32 &val) const
|
||||
{
|
||||
quint8 b;
|
||||
|
||||
val = 0;
|
||||
for (quint32 i = bytes; i; i--) {
|
||||
if (!readByte(hdl, b))
|
||||
return false;
|
||||
val |= ((quint32)b) << ((i-1) * 8);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readVUInt32(Handle &hdl, quint32 &val) const;
|
||||
bool readVUInt32SW(Handle &hdl, quint32 bytes, quint32 &val) const;
|
||||
bool readVBitfield32(Handle &hdl, quint32 &bitfield) const;
|
||||
|
||||
quint16 offset() const {return _blocks->first();}
|
||||
|
Loading…
Reference in New Issue
Block a user