Avoid unnecessary copying in copyIn
Only re-use the existing reference if it is large enough to hold all the new data. If it isn't then throw it away to avoid copying its current contents during the resize().
This commit is contained in:
@@ -1319,6 +1319,10 @@ public:
|
||||
{
|
||||
svector data;
|
||||
this->swap(data);
|
||||
// Will have to re-alloc anyway? If so avoid copying
|
||||
// data which will only be over-written
|
||||
if(data.capacity()<len)
|
||||
data.clear();
|
||||
data.resize(len);
|
||||
castUnsafeV(len, typeCode, (void*)data.data(), id, ptr);
|
||||
this->swap(data);
|
||||
|
||||
Reference in New Issue
Block a user