Skip to content
/ qTox Public
forked from TokTok/qTox

Commit

Permalink
cleanup: Use emplace_back instead of push_back.
Browse files Browse the repository at this point in the history
clang-tidy: modernize-use-emplace
  • Loading branch information
iphydf committed Jan 1, 2025
1 parent bee53bf commit 341084c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/chatlog/chatwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ void ChatWidget::handleSearchResult(SearchResult result, SearchDirection directi
jumpToIdx(searchPos.logIdx);
selectText();
} else {
renderCompletionFns.push_back(selectText);
renderCompletionFns.emplace_back(selectText);
jumpToIdx(searchPos.logIdx);
}
}
Expand Down Expand Up @@ -1224,7 +1224,7 @@ void ChatWidget::onScrollValueChanged(int value)
if (idx != chatLineStorage->firstIdx()) {
auto currentTop = (*chatLineStorage)[chatLineStorage->firstIdx()];

renderCompletionFns.push_back([this, currentTop] {
renderCompletionFns.emplace_back([this, currentTop] {
scrollToLine(currentTop);
scrollMonitoringEnabled = true;
});
Expand All @@ -1243,7 +1243,7 @@ void ChatWidget::onScrollValueChanged(int value)
auto currentBottomPx = (*chatLineStorage)[currentBottomIdx]->sceneBoundingRect().bottom();
auto bottomOffset = currentBottomPx - currentTopPx;

renderCompletionFns.push_back([this, currentBottomIdx, bottomOffset] {
renderCompletionFns.emplace_back([this, currentBottomIdx, bottomOffset] {
auto it = chatLineStorage->find(currentBottomIdx);
if (it != chatLineStorage->end()) {
updateSceneRect();
Expand Down Expand Up @@ -1516,7 +1516,7 @@ void ChatWidget::jumpToIdx(ChatLogIdx idx)

// If the requested idx is not currently rendered we need to request a
// render and jump to the requested line after the render completes
renderCompletionFns.push_back([this, idx] {
renderCompletionFns.emplace_back([this, idx] {
if (chatLineStorage->contains(idx)) {
scrollToLine((*chatLineStorage)[idx]);
}
Expand Down
3 changes: 1 addition & 2 deletions src/persistence/db/upgrades/dbto11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ bool DbTo11::getInvalidPeers(RawDatabase& db, std::vector<DbUpgrader::BadEntry>&
RawDatabase::Query("SELECT id, public_key FROM peers WHERE CAST(public_key AS BLOB) != "
"CAST(UPPER(public_key) AS BLOB)",
[&](const QVector<QVariant>& row) {
badPeers.emplace_back(
DbUpgrader::BadEntry{row[0].toInt(), row[1].toString()});
badPeers.emplace_back(row[0].toInt(), row[1].toString());
}));
}

Expand Down
5 changes: 2 additions & 3 deletions src/persistence/db/upgrades/dbupgrader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ std::vector<DbUpgrader::BadEntry> getInvalidPeers(RawDatabase& db)
std::vector<DbUpgrader::BadEntry> badPeerIds;
db.execNow(RawDatabase::Query("SELECT id, public_key FROM peers WHERE LENGTH(public_key) != 64",
[&](const QVector<QVariant>& row) {
badPeerIds.emplace_back(
DbUpgrader::BadEntry{row[0].toInt(), row[1].toString()});
badPeerIds.emplace_back(row[0].toInt(), row[1].toString());
}));
return badPeerIds;
}
Expand Down Expand Up @@ -83,7 +82,7 @@ DuplicateAlias getDuplicateAliasRows(RawDatabase& db, RowId goodPeerRow, RowId b
[&](const QVector<QVariant>& row) {
hasGoodEntry = true;
goodAliasRow = RowId{row[0].toInt()};
badAliasRows.emplace_back(RowId{row[1].toLongLong()});
badAliasRows.emplace_back(row[1].toLongLong());
}));

if (hasGoodEntry) {
Expand Down

0 comments on commit 341084c

Please sign in to comment.