Skip to content

Commit e5ba558

Browse files
committed
Fix error return-std-move
std::move should not be used here because it prevents RVO (copy elision) and it's considered an anti-pattern. To fix the original warning the returned type must match the declared return type or copy elision will not be possible (and the warning will be triggered).
1 parent 42ea216 commit e5ba558

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

external/o2/src/o2replyserver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ QMap<QString, QString> O2ReplyServer::parseQueryParams(QByteArray *data) {
9797
QUrlQuery query(getTokenUrl);
9898
tokens = query.queryItems();
9999
#endif
100-
QMultiMap<QString, QString> queryParams;
100+
QMap<QString, QString> queryParams;
101101
QPair<QString, QString> tokenPair;
102102
foreach (tokenPair, tokens) {
103103
// FIXME: We are decoding key and value again. This helps with Google OAuth, but is it mandated by the standard?
104104
QString key = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.first.trimmed().toLatin1()));
105105
QString value = QUrl::fromPercentEncoding(QByteArray().append(tokenPair.second.trimmed().toLatin1()));
106106
queryParams.insert(key, value);
107107
}
108-
return std::move( queryParams );
108+
return queryParams;
109109
}
110110

111111
void O2ReplyServer::closeServer(QTcpSocket *socket, bool hasparameters)

src/plugins/grass/qtermwidget/ColorScheme.cpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,25 @@ const char *const ColorScheme::translatedColorNames[TABLE_COLORS] =
125125

126126
ColorScheme::ColorScheme()
127127
{
128-
_table = 0;
129-
_randomTable = 0;
128+
_table = nullptr;
129+
_randomTable = nullptr;
130130
_opacity = 1.0;
131131
}
132132
ColorScheme::ColorScheme( const ColorScheme &other )
133133
: _opacity( other._opacity )
134-
, _table( 0 )
135-
, _randomTable( 0 )
134+
, _table( nullptr )
135+
, _randomTable( nullptr )
136136
{
137137
setName( other.name() );
138138
setDescription( other.description() );
139139

140-
if ( other._table != 0 )
140+
if ( other._table )
141141
{
142142
for ( int i = 0 ; i < TABLE_COLORS ; i++ )
143143
setColorTableEntry( i, other._table[i] );
144144
}
145145

146-
if ( other._randomTable != 0 )
146+
if ( other._randomTable )
147147
{
148148
for ( int i = 0 ; i < TABLE_COLORS ; i++ )
149149
{
@@ -188,7 +188,7 @@ ColorEntry ColorScheme::colorEntry( int index, uint randomSeed ) const
188188
ColorEntry entry = colorTable()[index];
189189

190190
if ( randomSeed != 0 &&
191-
_randomTable != 0 &&
191+
_randomTable &&
192192
!_randomTable[index].isNull() )
193193
{
194194
const RandomizationRange &range = _randomTable[index];
@@ -216,7 +216,7 @@ void ColorScheme::getColorTable( ColorEntry *table, uint randomSeed ) const
216216
}
217217
bool ColorScheme::randomizedBackgroundColor() const
218218
{
219-
return _randomTable == 0 ? false : !_randomTable[1].isNull();
219+
return _randomTable ? false : !_randomTable[1].isNull();
220220
}
221221
void ColorScheme::setRandomizedBackgroundColor( bool randomize )
222222
{
@@ -241,7 +241,7 @@ void ColorScheme::setRandomizationRange( int index, quint16 hue, quint8 saturati
241241
Q_ASSERT( hue <= MAX_HUE );
242242
Q_ASSERT( index >= 0 && index < TABLE_COLORS );
243243

244-
if ( _randomTable == 0 )
244+
if ( ! _randomTable )
245245
_randomTable = new RandomizationRange[TABLE_COLORS];
246246

247247
_randomTable[index].hue = hue;
@@ -696,15 +696,16 @@ QList<QString> ColorSchemeManager::listKDE3ColorSchemes()
696696
filters << QStringLiteral( "*.schema" );
697697
dir.setNameFilters( filters );
698698
QStringList list = dir.entryList( filters );
699-
QStringList ret;
699+
QList<QString> ret;
700700
foreach ( QString i, list )
701701
ret << dname + "/" + i;
702-
return std::move( ret );
702+
return ret;
703703
//return KGlobal::dirs()->findAllResources("data",
704704
// "konsole/*.schema",
705705
// KStandardDirs::NoDuplicates);
706706
//
707707
}
708+
708709
QList<QString> ColorSchemeManager::listColorSchemes()
709710
{
710711
QString dname( get_color_schemes_dir() );
@@ -713,10 +714,10 @@ QList<QString> ColorSchemeManager::listColorSchemes()
713714
filters << QStringLiteral( "*.colorscheme" );
714715
dir.setNameFilters( filters );
715716
QStringList list = dir.entryList( filters );
716-
QStringList ret;
717+
QList<QString> ret;
717718
foreach ( QString i, list )
718719
ret << dname + "/" + i;
719-
return std::move( ret );
720+
return ret;
720721
// return KGlobal::dirs()->findAllResources("data",
721722
// "konsole/*.colorscheme",
722723
// KStandardDirs::NoDuplicates);
@@ -778,11 +779,11 @@ const ColorScheme *ColorSchemeManager::findColorScheme( const QString &name )
778779

779780
qDebug() << "Could not find color scheme - " << name;
780781

781-
return 0;
782+
return nullptr;
782783
}
783784
}
784785

785-
ColorSchemeManager *ColorSchemeManager::sColorSchemeManager = 0;
786+
ColorSchemeManager *ColorSchemeManager::sColorSchemeManager = nullptr;
786787
//K_GLOBAL_STATIC( ColorSchemeManager , colorSchemeManager )
787788
ColorSchemeManager *ColorSchemeManager::instance()
788789
{

0 commit comments

Comments
 (0)