diff options
author | megamage <none@none> | 2009-06-01 12:15:43 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-06-01 12:15:43 -0500 |
commit | 11456447da10a3c96d74696a9bd003caebde9f7f (patch) | |
tree | ad30e139765d11b8afbcddc9f0bad622b45a3c85 | |
parent | 50015a1b4ee0082de09b0e0901b01b31b796a0e2 (diff) |
[7929] Some fixes and optimizations for work with packet guids. Author: VladimirMangos
* Allocate only minimal required buffer size for object packet guid cache, avoid it realocation.
* At adding aboyher buffer content copy only until wpos (really writed to buffer data)
* In appendPackGUID check buffer size before data write.
--HG--
branch : trunk
-rw-r--r-- | src/game/Object.cpp | 5 | ||||
-rw-r--r-- | src/shared/ByteBuffer.h | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 8c8c5772da7..f94ee52efdb 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -65,7 +65,7 @@ uint32 GuidHigh2TypeId(uint32 guid_hi) return NUM_CLIENT_OBJECT_TYPES; // unknown } -Object::Object( ) +Object::Object( ) : m_PackGUID(sizeof(uint64)+1) { m_objectTypeId = TYPEID_OBJECT; m_objectType = TYPEMASK_OBJECT; @@ -77,7 +77,6 @@ Object::Object( ) m_inWorld = false; m_objectUpdated = false; - m_PackGUID.clear(); m_PackGUID.appendPackGUID(0); } @@ -123,7 +122,7 @@ void Object::_Create( uint32 guidlow, uint32 entry, HighGuid guidhigh ) uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh); SetUInt64Value( OBJECT_FIELD_GUID, guid ); SetUInt32Value( OBJECT_FIELD_TYPE, m_objectType ); - m_PackGUID.clear(); + m_PackGUID.wpos(0); m_PackGUID.appendPackGUID(GetGUID()); } diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 7dc6b5483df..f11746b8ce5 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -311,11 +311,14 @@ class ByteBuffer } void append(const ByteBuffer& buffer) { - if(buffer.size()) append(buffer.contents(),buffer.size()); + if(buffer.size()) append(buffer.contents(),buffer.wpos()); } void appendPackGUID(uint64 guid) { + if (_storage.size() < _wpos + sizeof(guid) + 1) + _storage.resize(_wpos + sizeof(guid) + 1); + size_t mask_position = wpos(); *this << uint8(0); for(uint8 i = 0; i < 8; i++) |