avoid reallocating the buffer in case we're being called repeatedly on
a fixed-size buffer
This commit is contained in:
@@ -136,7 +136,6 @@ int RageFileObj::Read( void *pBuffer, size_t iBytes )
|
|||||||
|
|
||||||
int RageFileObj::Read( CString &sBuffer, int iBytes )
|
int RageFileObj::Read( CString &sBuffer, int iBytes )
|
||||||
{
|
{
|
||||||
sBuffer.erase( sBuffer.begin(), sBuffer.end() );
|
|
||||||
sBuffer.reserve( iBytes != -1? iBytes: this->GetFileSize() );
|
sBuffer.reserve( iBytes != -1? iBytes: this->GetFileSize() );
|
||||||
|
|
||||||
int iRet = 0;
|
int iRet = 0;
|
||||||
@@ -157,6 +156,8 @@ int RageFileObj::Read( CString &sBuffer, int iBytes )
|
|||||||
iRet += iGot;
|
iRet += iGot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sBuffer.erase( sBuffer.begin()+iRet );
|
||||||
|
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user