Performance improvements to savegame loading

This commit is contained in:
Jonathan G Rennison
2018-05-28 02:22:26 +01:00
parent 8404afd40f
commit 3b83a9e186
2 changed files with 136 additions and 34 deletions

View File

@@ -679,24 +679,9 @@ size_t SlCalcObjLength(const void *object, const SaveLoad *sld);
byte SlReadByte();
void SlWriteByte(byte b);
static inline int SlReadUint16()
{
int x = SlReadByte() << 8;
return x | SlReadByte();
}
static inline uint32 SlReadUint32()
{
uint32 x = SlReadUint16() << 16;
return x | SlReadUint16();
}
static inline uint64 SlReadUint64()
{
uint32 x = SlReadUint32();
uint32 y = SlReadUint32();
return (uint64)x << 32 | y;
}
int SlReadUint16();
uint32 SlReadUint32();
uint64 SlReadUint64();
static inline void SlWriteUint16(uint16 v)
{
@@ -716,15 +701,7 @@ static inline void SlWriteUint64(uint64 x)
SlWriteUint32((uint32)x);
}
/**
* Read in bytes from the file/data structure but don't do
* anything with them, discarding them in effect
* @param length The amount of bytes that is being treated this way
*/
static inline void SlSkipBytes(size_t length)
{
for (; length != 0; length--) SlReadByte();
}
void SlSkipBytes(size_t length);
size_t SlGetBytesRead();
size_t SlGetBytesWritten();