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:
1 parent
54ee8bf7a0
commit
9e865bc37d
1 file changed
+4
@@ -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