From 139694fce36a74031c968b5fade5fd97c3731e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Tue, 27 Nov 2018 08:20:02 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@664 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/containers/pivector.h | 3 +++ src_main/containers/pivector2d.h | 16 +++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src_main/containers/pivector.h b/src_main/containers/pivector.h index a113addd..f1934615 100755 --- a/src_main/containers/pivector.h +++ b/src_main/containers/pivector.h @@ -212,6 +212,9 @@ public: assert(0); return *this; } + inline void _copyRaw(T * dst, const T * src, size_t size) { + newT(dst, src, size); + } inline PIVector & reserve(size_t new_size) { if (new_size <= piv_rsize) return *this; diff --git a/src_main/containers/pivector2d.h b/src_main/containers/pivector2d.h index eb40dcfa..7a798128 100644 --- a/src_main/containers/pivector2d.h +++ b/src_main/containers/pivector2d.h @@ -85,12 +85,12 @@ public: inline Row & operator =(const Row & other) { if (p_ == other.p_ && st_ == other.st_) return *this; size_t sz = piMin(sz_, other.sz_); - copyRow(st_, other.data(), sz, p_); + p_->_copyRaw(p_->data(st_), other.data(), sz); return *this; } inline Row & operator =(const PIVector & other) { size_t sz = piMin(sz, other.size()); - copyRow(st_, other.data(), sz, p_); + p_->_copyRaw(p_->data(st_), other.data(), sz); return *this; } inline PIVector toVector() const {return PIVector(p_->data(st_), sz_);} @@ -153,7 +153,7 @@ public: inline PIVector toVector() const { PIVector ret; ret.reserve(sz_); - for (int i=0; i & setRow(size_t row, const Row & other) { size_t sz = piMin(cols_, other.p_->cols_); - copyRow(cols_ * row, other.data(), sz, &mat); + mat._copyRaw(mat.data(cols_ * row), other.data(), sz); return *this; } inline PIVector2D & setRow(size_t row, const PIVector & other) { size_t sz = piMin(cols_, other.size()); - copyRow(cols_ * row, other.data(), sz, &mat); + mat._copyRaw(mat.data(cols_ * row), other.data(), sz); return *this; } @@ -203,11 +203,6 @@ public: } protected: - inline void copyRow(size_t start, const T * data, size_t size, PIVector * dst) { - for (size_t i = 0; i < size; i++) - (*dst)[start + i] = data[i]; - } - size_t rows_, cols_; PIVector mat; }; @@ -233,7 +228,6 @@ inline PICout operator <<(PICout s, const PIVector2D & v) { } #define __PIVECTOR2D_SIMPLE_TYPE__(T) \ - template<> inline void PIVector2D::copyRow(size_t start, const T * data, size_t size, PIVector * dst) {memcpy(dst->data(start), data, size * sizeof(T));} \ template<> inline PIVector2D & PIVector2D::_resizeRaw(size_t r, size_t c) {rows_ = r; cols_ = c; mat._resizeRaw(r*c); return *this;} __PIVECTOR2D_SIMPLE_TYPE__(bool)