mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-19 08:30:34 +01:00
Core/Misc: Optimized ByteBuffer::ReadString
This commit is contained in:
@@ -498,13 +498,16 @@ class ByteBuffer
|
||||
|
||||
std::string ReadString(uint32 length)
|
||||
{
|
||||
if (_rpos + length > size())
|
||||
throw ByteBufferPositionException(false, _rpos, length, size());
|
||||
|
||||
if (!length)
|
||||
return std::string();
|
||||
char* buffer = new char[length + 1];
|
||||
read((uint8*)buffer, length);
|
||||
std::string retval = buffer;
|
||||
delete[] buffer;
|
||||
return retval;
|
||||
|
||||
ResetBitPos();
|
||||
std::string str((char const*)&_storage[_rpos], length);
|
||||
_rpos += length;
|
||||
return str;
|
||||
}
|
||||
|
||||
//! Method for writing strings that have their length sent separately in packet
|
||||
|
||||
Reference in New Issue
Block a user