[Libreoffice-commits] core.git: drawinglayer/source include/drawinglayer
Noel Grandin
noel at peralex.com
Tue Dec 15 00:17:46 PST 2015
drawinglayer/source/primitive2d/baseprimitive2d.cxx | 15 ++++++++-------
include/drawinglayer/primitive2d/baseprimitive2d.hxx | 12 ++++++++----
2 files changed, 16 insertions(+), 11 deletions(-)
New commits:
commit 9c9291255f474b396813256050b84ffd425002aa
Author: Noel Grandin <noel at peralex.com>
Date: Fri Dec 11 14:59:12 2015 +0200
create a move append method for Primitive2DContainer
since it is fairly common to append temporaries.
Change-Id: I920daf8539e42fc9fe313af48fdb34ee4aaf908d
Reviewed-on: https://gerrit.libreoffice.org/20637
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
Tested-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
index 1f5e5dd..795c609 100644
--- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx
@@ -312,16 +312,17 @@ namespace drawinglayer
{
insert(end(), rSource.begin(), rSource.end());
}
-/*
+
void Primitive2DContainer::append(Primitive2DContainer&& rSource)
{
- resize(size() + rSource.size());
- memcpy(data() + size(),
- rSource.data(),
- rSource.size() * sizeof(Primitive2DReference));
- memset(reinterpret_cast<void*>(rSource.data()), 0, rSource.size() * sizeof(Primitive2DReference));
+ size_t n = size();
+ resize(n + rSource.size());
+ for (size_t i = 0; i<rSource.size(); ++i)
+ {
+ (*this)[n + i] = std::move( rSource[i] );
+ }
}
-*/
+
void Primitive2DContainer::append(const Primitive2DSequence& rSource)
{
std::copy(rSource.begin(), rSource.end(), std::back_inserter(*this));
diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
index 850fd2e..c297421 100644
--- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
@@ -58,13 +58,17 @@ namespace drawinglayer { namespace primitive2d {
{
public:
explicit Primitive2DContainer() {}
- explicit Primitive2DContainer( size_type count ) : std::vector< Primitive2DReference >(count) {}
- Primitive2DContainer( const Primitive2DContainer& other ) : std::vector< Primitive2DReference >(other) {}
- Primitive2DContainer( const std::vector< Primitive2DReference >& other ) : std::vector< Primitive2DReference >(other) {}
- Primitive2DContainer( std::initializer_list<Primitive2DReference> init ) : std::vector< Primitive2DReference >(init) {}
+ explicit Primitive2DContainer( size_type count ) : vector(count) {}
+ Primitive2DContainer( const Primitive2DContainer& other ) : vector(other) {}
+ Primitive2DContainer( const Primitive2DContainer&& other ) : vector(other) {}
+ Primitive2DContainer( const vector< Primitive2DReference >& other ) : vector(other) {}
+ Primitive2DContainer( std::initializer_list<Primitive2DReference> init ) : vector(init) {}
void append(const Primitive2DContainer& rSource);
void append(const Primitive2DSequence& rSource);
+ void append(Primitive2DContainer&& rSource);
+ Primitive2DContainer& operator=(const Primitive2DContainer& r) { vector::operator=(r); return *this; }
+ Primitive2DContainer& operator=(const Primitive2DContainer&& r) { vector::operator=(r); return *this; }
bool operator==(const Primitive2DContainer& rB) const;
bool operator!=(const Primitive2DContainer& rB) const { return !operator==(rB); }
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& aViewInformation) const;
More information about the Libreoffice-commits
mailing list