Commit 993c96a0 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Micro optimizations

Summary:
Add some const & for things that return const & so there's no need to make a copy
Add a std::move for a thing that we pass by copy and it's just saved in another variable

Reviewers: zzag

Reviewed By: zzag

Subscribers: zzag, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24614
parent c96594d7
......@@ -52,7 +52,7 @@ namespace Breeze
{
const ScrollBarData* scrollBarData( static_cast<const ScrollBarData*>( data.data() ) );
Animation::Pointer animation = scrollBarData->animation( control );
const Animation::Pointer &animation = scrollBarData->animation( control );
return animation.data()->isRunning();
} else return false;
......
......@@ -151,7 +151,7 @@ namespace Breeze
void FrameShadowFactory::updateShadowsGeometry( const QObject* object, QRect rect ) const
{
const QList<QObject *> children = object->children();
const QList<QObject *> &children = object->children();
foreach( QObject *child, children )
{
if( FrameShadow* shadow = qobject_cast<FrameShadow *>(child) )
......@@ -164,7 +164,7 @@ namespace Breeze
void FrameShadowFactory::raiseShadows( QObject* object ) const
{
const QList<QObject *> children = object->children();
const QList<QObject *> &children = object->children();
foreach( QObject *child, children )
{
if( FrameShadow* shadow = qobject_cast<FrameShadow *>(child) )
......@@ -177,7 +177,7 @@ namespace Breeze
void FrameShadowFactory::update( QObject* object ) const
{
const QList<QObject* > children = object->children();
const QList<QObject* > &children = object->children();
foreach( QObject *child, children )
{
if( FrameShadow* shadow = qobject_cast<FrameShadow *>(child) )
......@@ -190,7 +190,7 @@ namespace Breeze
void FrameShadowFactory::updateState( const QWidget* widget, bool focus, bool hover, qreal opacity, AnimationMode mode ) const
{
const QList<QObject *> children = widget->children();
const QList<QObject *> &children = widget->children();
foreach( QObject *child, children )
{
if( FrameShadow* shadow = qobject_cast<FrameShadow *>(child) )
......
......@@ -42,7 +42,7 @@ namespace Breeze
//____________________________________________________________________
Helper::Helper( KSharedConfig::Ptr config ):
_config( config )
_config( std::move( config ) )
{ init(); }
//____________________________________________________________________
......@@ -128,7 +128,7 @@ namespace Breeze
{
QColor outline( palette.color( QPalette::Inactive, QPalette::Highlight ) );
QColor focus( palette.color( QPalette::Active, QPalette::Highlight ) );
const QColor &focus = palette.color( QPalette::Active, QPalette::Highlight );
if( mode == AnimationFocus )
{
......
......@@ -33,7 +33,7 @@ namespace Breeze
{
//____________________________________________________________________
MdiWindowShadow::MdiWindowShadow( QWidget* parent, TileSet shadowTiles ):
MdiWindowShadow::MdiWindowShadow( QWidget* parent, const TileSet &shadowTiles ):
QWidget( parent ),
_shadowTiles( shadowTiles )
{
......
......@@ -45,7 +45,7 @@ namespace Breeze
public:
//* constructor
explicit MdiWindowShadow( QWidget*, TileSet );
explicit MdiWindowShadow( QWidget*, const TileSet & );
//* update geometry
void updateGeometry();
......
......@@ -3112,7 +3112,7 @@ namespace Breeze
if( rect.height() < 2*Metrics::LineEdit_FrameWidth + option->fontMetrics.height())
{
const auto background( palette.color( QPalette::Base ) );
const auto &background = palette.color( QPalette::Base );
painter->setPen( Qt::NoPen );
painter->setBrush( background );
......@@ -3136,7 +3136,7 @@ namespace Breeze
const qreal opacity( _animations->inputWidgetEngine().frameOpacity( widget ) );
// render
const auto background( palette.color( QPalette::Base ) );
const auto &background = palette.color( QPalette::Base );
const auto outline( _helper->frameOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) );
_helper->renderFrame( painter, rect, background, outline );
......@@ -3729,7 +3729,7 @@ namespace Breeze
{ _shadowHelper->registerWidget( widget->window(), true ); }
const auto& palette( option->palette );
const auto background( palette.color( QPalette::ToolTipBase ) );
const auto &background = palette.color( QPalette::ToolTipBase );
const auto outline( KColorUtils::mix( palette.color( QPalette::ToolTipBase ), palette.color( QPalette::ToolTipText ), 0.25 ) );
const bool hasAlpha( _helper->hasAlphaChannel( widget ) );
......@@ -5043,7 +5043,7 @@ namespace Breeze
const qreal progress( _animations->busyIndicatorEngine().value() );
const auto first( palette.color( QPalette::Highlight ) );
const auto &first = palette.color( QPalette::Highlight );
const auto second( KColorUtils::mix( palette.color( QPalette::Highlight ), palette.color( QPalette::Window ), 0.7 ) );
_helper->renderProgressBarBusyContents( painter, rect, first, second, horizontal, reverse, progress );
......@@ -5271,7 +5271,7 @@ namespace Breeze
// colors
const auto& palette( option->palette );
const auto background( palette.color( QPalette::Window ) );
const auto &background = palette.color( QPalette::Window );
// adjust rect, based on number of buttons to be drawn
const auto rect( scrollBarInternalSubControlRect( sliderOption, SC_ScrollBarSubLine ) );
......@@ -5425,7 +5425,7 @@ namespace Breeze
const qreal opacity( _animations->headerViewEngine().opacity( widget, rect.topLeft() ) );
// fill
const auto normal( palette.color( QPalette::Button ) );
const auto &normal = palette.color( QPalette::Button );
const auto focus( KColorUtils::mix( normal, _helper->focusColor( palette ), 0.2 ) );
const auto hover( KColorUtils::mix( normal, _helper->hoverColor( palette ), 0.2 ) );
......@@ -6194,7 +6194,7 @@ namespace Breeze
if( flat )
{
const auto background( palette.color( QPalette::Base ) );
const auto &background = palette.color( QPalette::Base );
painter->setBrush( background );
painter->setPen( Qt::NoPen );
......@@ -6322,7 +6322,7 @@ namespace Breeze
if( flat )
{
const auto background( palette.color( QPalette::Base ) );
const auto &background = palette.color( QPalette::Base );
painter->setBrush( background );
painter->setPen( Qt::NoPen );
......@@ -6395,7 +6395,7 @@ namespace Breeze
// colors
const auto base( _helper->separatorColor( palette ) );
const auto highlight( palette.color( QPalette::Highlight ) );
const auto &highlight = palette.color( QPalette::Highlight );
while( current <= sliderOption->maximum )
{
......@@ -6437,7 +6437,7 @@ namespace Breeze
auto handleRect( subControlRect( CC_Slider, sliderOption, SC_SliderHandle, widget ) );
// highlight color
const auto highlight( palette.color( QPalette::Highlight ) );
const auto &highlight = palette.color( QPalette::Highlight );
if( sliderOption->orientation == Qt::Horizontal )
{
......@@ -6484,7 +6484,7 @@ namespace Breeze
const qreal opacity( _animations->widgetStateEngine().buttonOpacity( widget ) );
// define colors
const auto background( palette.color( QPalette::Button ) );
const auto &background = palette.color( QPalette::Button );
const auto outline( _helper->sliderOutlineColor( palette, handleActive && mouseOver, hasFocus, opacity, mode ) );
const auto shadow( _helper->shadowColor( palette ) );
......@@ -6535,7 +6535,7 @@ namespace Breeze
{
// highlight
const auto highlight( palette.color( QPalette::Highlight ) );
const auto &highlight = palette.color( QPalette::Highlight );
// angles
const qreal second( dialAngle( sliderOption, sliderOption->sliderPosition ) );
......@@ -6567,7 +6567,7 @@ namespace Breeze
const qreal opacity( _animations->dialEngine().buttonOpacity( widget ) );
// define colors
const auto background( palette.color( QPalette::Button ) );
const auto &background = palette.color( QPalette::Button );
const auto outline( _helper->sliderOutlineColor( palette, handleActive && mouseOver, hasFocus, opacity, mode ) );
const auto shadow( _helper->shadowColor( palette ) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment