Optimized String usage

It will no longer initialize the buffer if not necessary


Former-commit-id: b8c910268ed3db6affb8f88b45d043d1dc021aa7
This commit is contained in:
Lynix
2014-03-15 00:26:29 +01:00
parent 268d3ae86d
commit 970c0c8ef8
5 changed files with 9 additions and 13 deletions

View File

@@ -47,10 +47,10 @@ NzString NzInputStream::ReadLine(unsigned int lineSize)
}
else
{
line.Resize(lineSize);
line.Set(lineSize, '\0');
unsigned int readSize = Read(&line[0], lineSize);
unsigned int pos = line.Find('\n');
if (pos <= readSize) // Forcément trouvé, npos étant le plus grand des entiers
if (pos <= readSize) // Faux uniquement si le caractère n'est pas présent (npos étant le plus grand entier)
{
if (m_streamOptions & nzStreamOption_Text && pos > 0 && line[pos-1] == '\r')
line.Resize(pos);