From 9e865bc37d8e0c726cc4e698b10f9d568876ca79 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 23 May 2013 18:19:26 -0400 Subject: [PATCH] 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(). --- pvDataApp/pv/pvData.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pvDataApp/pv/pvData.h b/pvDataApp/pv/pvData.h index 78bffe9..536a8ae 100644 --- a/pvDataApp/pv/pvData.h +++ b/pvDataApp/pv/pvData.h @@ -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()swap(data);