de-inlined two functions that were generating too much code.

This commit is contained in:
Christoph Oelckers 2023-12-16 10:58:04 +01:00
parent 08614613be
commit 633c09a3bb
2 changed files with 28 additions and 24 deletions

View file

@ -265,36 +265,14 @@ public:
return mReader->Read(buffer, len);
}
FileData Read(size_t len)
{
FileData buffer;
if (len > 0)
{
Size length = mReader->Read(buffer.allocate(len), len);
if ((size_t)length < len) buffer.allocate(length);
}
return buffer;
}
FileData Read(size_t len);
FileData ReadPadded(size_t padding);
FileData Read()
{
return Read(GetLength());
}
FileData ReadPadded(size_t padding)
{
auto len = GetLength();
FileData buffer;
if (len > 0)
{
auto p = (char*)buffer.allocate(len + padding);
Size length = mReader->Read(p, len);
if (length < len) buffer.clear();
else memset(p + len, 0, padding);
}
return buffer;
}
char *Gets(char *strbuf, Size len)
{

View file

@ -402,6 +402,32 @@ bool FileReader::OpenMemoryArray(FileData& data)
return true;
}
FileData FileReader::Read(size_t len)
{
FileData buffer;
if (len > 0)
{
Size length = mReader->Read(buffer.allocate(len), len);
if ((size_t)length < len) buffer.allocate(length);
}
return buffer;
}
FileData FileReader::ReadPadded(size_t padding)
{
auto len = GetLength();
FileData buffer;
if (len > 0)
{
auto p = (char*)buffer.allocate(len + padding);
Size length = mReader->Read(p, len);
if (length < len) buffer.clear();
else memset(p + len, 0, padding);
}
return buffer;
}
//==========================================================================