From 40d0c729827d4fd4ea01039474e4b274536096f0 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 13 Feb 2019 02:23:56 +0100 Subject: [PATCH] Use memcpy and memset instead of per-element copy and zero. --- server/TracyVector.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/server/TracyVector.hpp b/server/TracyVector.hpp index 68777c41..a565259d 100644 --- a/server/TracyVector.hpp +++ b/server/TracyVector.hpp @@ -30,13 +30,9 @@ public: Vector( const Vector& ) = delete; Vector( Vector&& src ) noexcept - : m_ptr( src.m_ptr ) - , m_size( src.m_size ) - , m_capacity( src.m_capacity ) { - src.m_ptr = nullptr; - src.m_size = 0; - src.m_capacity = 0; + memcpy( this, &src, sizeof( Vector ) ); + memset( &src, 0, sizeof( Vector ) ); } Vector( const T& value ) @@ -65,12 +61,8 @@ public: Vector& operator=( Vector&& src ) noexcept { delete[] m_ptr; - m_ptr = src.m_ptr; - m_size = src.m_size; - m_capacity = src.m_capacity; - src.m_ptr = nullptr; - src.m_size = 0; - src.m_capacity = 0; + memcpy( this, &src, sizeof( Vector ) ); + memset( &src, 0, sizeof( Vector ) ); return *this; }