Skip to content

Commit

Permalink
Add move operators to QgsEffectStack
Browse files Browse the repository at this point in the history
Results in a (very slight) performance boost with symbol copies
  • Loading branch information
nyalldawson committed Jul 23, 2019
1 parent 2cd5334 commit 751f154
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/auto_generated/effects/qgseffectstack.sip.in
Expand Up @@ -51,6 +51,7 @@ Constructor for empty QgsEffectStack.

QgsEffectStack( const QgsEffectStack &other );


explicit QgsEffectStack( const QgsPaintEffect &effect );
%Docstring
Creates a new QgsEffectStack effect from a single initial effect.
Expand Down Expand Up @@ -145,6 +146,8 @@ Returns a pointer to the effect at a specified index within the stack
%End




protected:

virtual void draw( QgsRenderContext &context );
Expand Down
13 changes: 13 additions & 0 deletions src/core/effects/qgseffectstack.cpp
Expand Up @@ -31,6 +31,12 @@ QgsEffectStack::QgsEffectStack( const QgsEffectStack &other )
}
}

QgsEffectStack::QgsEffectStack( QgsEffectStack &&other )
: QgsPaintEffect( other )
{
std::swap( mEffectList, other.mEffectList );
}

QgsEffectStack::QgsEffectStack( const QgsPaintEffect &effect )
{
appendEffect( effect.clone() );
Expand All @@ -56,6 +62,13 @@ QgsEffectStack &QgsEffectStack::operator=( const QgsEffectStack &rhs )
return *this;
}

QgsEffectStack &QgsEffectStack::operator=( QgsEffectStack &&other )
{
std::swap( mEffectList, other.mEffectList );
mEnabled = other.enabled();
return *this;
}

QgsPaintEffect *QgsEffectStack::create( const QgsStringMap &map )
{
QgsEffectStack *effect = new QgsEffectStack();
Expand Down
8 changes: 8 additions & 0 deletions src/core/effects/qgseffectstack.h
Expand Up @@ -61,6 +61,11 @@ class CORE_EXPORT QgsEffectStack : public QgsPaintEffect

QgsEffectStack( const QgsEffectStack &other );

/**
* Move constructor.
*/
QgsEffectStack( QgsEffectStack &&other ) SIP_SKIP;

/**
* Creates a new QgsEffectStack effect from a single initial effect.
* \param effect initial effect to add to the stack. The effect will
Expand Down Expand Up @@ -139,6 +144,9 @@ class CORE_EXPORT QgsEffectStack : public QgsPaintEffect

QgsEffectStack &operator=( const QgsEffectStack &rhs );

QgsEffectStack &operator=( QgsEffectStack &&other ) SIP_SKIP;


protected:

void draw( QgsRenderContext &context ) override;
Expand Down

0 comments on commit 751f154

Please sign in to comment.