Skip to content

Commit

Permalink
used << instead of append() for lists everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Dec 15, 2022
1 parent afdea43 commit a7a8dea
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion include/orm/query/querybuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ namespace Orm::Query
Builder::crossJoin(T &&table)
{
// No need to call joinInternal() because no bindings
m_joins.append(newJoinClause(*this, CROSS, std::forward<T>(table)));
m_joins << newJoinClause(*this, CROSS, std::forward<T>(table));

return *this;
}
Expand Down
12 changes: 6 additions & 6 deletions include/orm/tiny/concerns/guardsattributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace Orm::Tiny::Concerns

for (const auto &value : fillable)
if (!fillable_.contains(value))
fillable_.append(value);
fillable_ << value;

return model();
}
Expand All @@ -140,7 +140,7 @@ namespace Orm::Tiny::Concerns

for (auto &value : fillable)
if (!fillable_.contains(value))
fillable_.append(std::move(value));
fillable_ << std::move(value);

return model();
}
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace Orm::Tiny::Concerns

for (const auto &value : guarded)
if (!guarded_.contains(value))
guarded_.append(value);
guarded_ << value;

return model();
}
Expand All @@ -191,7 +191,7 @@ namespace Orm::Tiny::Concerns

for (auto &value : guarded)
if (!guarded_.contains(value))
guarded_.append(std::move(value));
guarded_ << std::move(value);

return model();
}
Expand Down Expand Up @@ -288,7 +288,7 @@ namespace Orm::Tiny::Concerns

for (const auto &attribute : attributes)
if (fillable.contains(attribute.key))
result.append(attribute);
result << attribute;

return result;
}
Expand All @@ -307,7 +307,7 @@ namespace Orm::Tiny::Concerns

for (auto &attribute : attributes)
if (fillable.contains(attribute.key))
result.append(std::move(attribute));
result << std::move(attribute);

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion include/orm/tiny/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ namespace Orm::Tiny
template<typename Derived, AllRelationsConcept ...AllRelations>
void Model<Derived, AllRelations...>::appendToUserDates(const QString &column)
{
const_cast<QStringList &>(Derived::u_dates).append(column);
const_cast<QStringList &>(Derived::u_dates) << column;
}

} // namespace Orm::Tiny
Expand Down
2 changes: 1 addition & 1 deletion include/orm/tiny/relations/belongstomany.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ namespace Orm::Tiny::Relations
->getAttribute(m_foreignPivotKey)
.template value<typename Model::KeyType>();

dictionary[foreignPivotKey].append(std::move(result));
dictionary[foreignPivotKey] << std::move(result);
}

return dictionary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ namespace Concerns

// FEATURE pivot, withPivotValues silverqx
// for (auto &[column, value] as m_pivotValues)
// record.append(column, value);
// record << column, value;

return record;
}
Expand Down
2 changes: 1 addition & 1 deletion include/orm/tiny/relations/hasoneormany.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ namespace Orm::Tiny::Relations
.template value<typename Model::KeyType>();
std::is_same_v<RelationType, QVector<Related>>
)
dictionary[foreign].append(std::move(result));
dictionary[foreign] << std::move(result);
else
// Moves to the std::optional
dictionary.insert(foreign, std::move(result));
Expand Down
2 changes: 1 addition & 1 deletion src/orm/query/grammars/grammar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ Grammar::flatBindingsForUpdateDelete(const BindingsMap &bindings,
continue;
else
for (const auto &binding : itBindings.value())
cleanBindingsFlatten.append(std::cref(binding));
cleanBindingsFlatten << std::cref(binding);

return cleanBindingsFlatten;
}
Expand Down
2 changes: 1 addition & 1 deletion src/orm/query/processors/mysqlprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ QStringList MySqlProcessor::processColumnListing(SqlQuery &query) const
columns.reserve(QueryUtils::queryResultSize(query));

while (query.next())
columns.append(query.value("column_name").value<QString>());
columns << query.value("column_name").value<QString>();

return columns;
}
Expand Down
2 changes: 1 addition & 1 deletion src/orm/query/processors/postgresprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ QStringList PostgresProcessor::processColumnListing(SqlQuery &query) const
columns.reserve(QueryUtils::queryResultSize(query));

while (query.next())
columns.append(query.value("column_name").value<QString>());
columns << query.value("column_name").value<QString>();

return columns;
}
Expand Down
2 changes: 1 addition & 1 deletion src/orm/query/processors/sqliteprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ QStringList SQLiteProcessor::processColumnListing(SqlQuery &query) const
columns.reserve(QueryUtils::queryResultSize(query));

while (query.next())
columns.append(query.value(NAME).value<QString>());
columns << query.value(NAME).value<QString>();

return columns;
}
Expand Down
10 changes: 5 additions & 5 deletions src/orm/query/querybuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ Builder &Builder::groupBy(const Column &group)

Builder &Builder::groupByRaw(const QString &sql, const QVector<QVariant> &bindings)
{
m_groups.append(Expression(sql));
m_groups << Expression(sql);

addBinding(bindings, BindingType::GROUPBY);

Expand Down Expand Up @@ -1246,7 +1246,7 @@ QVector<QVariant> Builder::getBindings() const

for (const auto &bindings : std::as_const(m_bindings))
for (const auto &binding : bindings)
flattenBindings.append(binding);
flattenBindings << binding;

return flattenBindings;
}
Expand All @@ -1258,7 +1258,7 @@ Builder &Builder::addBinding(const QVariant &binding, const BindingType type)
checkBindingType(type);
#endif

m_bindings[type].append(binding);
m_bindings[type] << binding;

return *this;
}
Expand All @@ -1270,7 +1270,7 @@ Builder &Builder::addBinding(QVariant &&binding, const BindingType type)
checkBindingType(type);
#endif

m_bindings[type].append(std::move(binding));
m_bindings[type] << std::move(binding);

return *this;
}
Expand Down Expand Up @@ -1689,7 +1689,7 @@ Builder &Builder::joinInternal(std::shared_ptr<JoinClause> &&join)
const auto &joinRef = *join;

// Move ownership
m_joins.append(std::move(join));
m_joins << std::move(join);

addBinding(joinRef.getBindings(), BindingType::JOIN);

Expand Down
2 changes: 1 addition & 1 deletion src/orm/schema/blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void Blueprint::defaultStringLength(const int length) noexcept

ColumnDefinitionReference<> Blueprint::addColumnDefinition(ColumnDefinition &&definition)
{
m_columns.append(std::move(definition));
m_columns << std::move(definition);

auto &definitionRef = m_columns.last(); // clazy:exclude=detaching-member

Expand Down
16 changes: 8 additions & 8 deletions tests/auto/functional/orm/tiny/softdeletes/tst_softdeletes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void tst_SoftDeletes::restore_remove_OnTinyBuilder() const
QCOMPARE(user.getAttribute(DELETED_AT).value<QDateTime>(), QDateTime());
QVERIFY(!user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -428,7 +428,7 @@ void tst_SoftDeletes::restore_remove_OnTinyBuilder() const
timeBeforeRemove);
QVERIFY(user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -606,7 +606,7 @@ void tst_SoftDeletes::restore_Trashed_OnTinyBuilder() const
QCOMPARE(user.getAttribute(DELETED_AT).value<QDateTime>(), QDateTime());
QVERIFY(!user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -771,7 +771,7 @@ void tst_SoftDeletes::restore_NotTrashed_OnTinyBuilder() const
QCOMPARE(user.getAttribute(DELETED_AT).value<QDateTime>(), QDateTime());
QVERIFY(!user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -811,7 +811,7 @@ void tst_SoftDeletes::restore_NotTrashed_OnTinyBuilder() const
QCOMPARE(user.getAttribute(DELETED_AT).value<QDateTime>(), QDateTime());
QVERIFY(!user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -996,7 +996,7 @@ void tst_SoftDeletes::remove_Trashed_OnTinyBuilder() const
timeBeforeRemove);
QVERIFY(user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -1160,7 +1160,7 @@ void tst_SoftDeletes::remove_NotTrashed_OnTinyBuilder() const
QCOMPARE(user.getAttribute(DELETED_AT).value<QDateTime>(), QDateTime());
QVERIFY(!user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down Expand Up @@ -1201,7 +1201,7 @@ void tst_SoftDeletes::remove_NotTrashed_OnTinyBuilder() const
timeBeforeRemove);
QVERIFY(user.trashed());

actualIds.append(user.getAttribute(ID).value<quint64>());
actualIds << user.getAttribute(ID).value<quint64>();
}

QCOMPARE(actualIds, expectedIds);
Expand Down

0 comments on commit a7a8dea

Please sign in to comment.