mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-15 00:42:20 +00:00
de-inlined two functions that were generating too much code.
This commit is contained in:
parent
08614613be
commit
633c09a3bb
2 changed files with 28 additions and 24 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue