Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: Use emplace_back instead of push_back. #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1518,7 +1518,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
Loading