Apply autofixes from clazy

This commit is contained in:
Ilya Fedin 2021-03-13 12:26:58 +04:00 committed by John Preston
parent c9934c142d
commit f25b2a2094
35 changed files with 49 additions and 49 deletions

View File

@ -51,7 +51,7 @@ JoinedByLinkSlice ParseJoinedByLinkSlice(
owner.processUsers(data.vusers());
result.count = data.vcount().v;
result.users.reserve(data.vimporters().v.size());
for (const auto importer : data.vimporters().v) {
for (const auto &importer : data.vimporters().v) {
importer.match([&](const MTPDchatInviteImporter &data) {
result.users.push_back({
.user = owner.user(data.vuser_id().v),

View File

@ -242,7 +242,7 @@ Updates::Updates(not_null<Main::Session*> session)
}) | rpl::start_with_next([=](not_null<PeerData*> peer) {
if (const auto list = _pendingSpeakingCallParticipants.take(peer)) {
if (const auto call = peer->groupCall()) {
for (const auto [participantPeerId, when] : *list) {
for (const auto &[participantPeerId, when] : *list) {
call->applyActiveUpdate(
participantPeerId,
Data::LastSpokeTimes{

View File

@ -525,7 +525,7 @@ void ApiWrap::sendMessageFail(
link)));
} else if (error.type().startsWith(qstr("SLOWMODE_WAIT_"))) {
const auto chop = qstr("SLOWMODE_WAIT_").size();
const auto left = error.type().mid(chop).toInt();
const auto left = error.type().midRef(chop).toInt();
if (const auto channel = peer->asChannel()) {
const auto seconds = channel->slowmodeSeconds();
if (seconds >= left) {

View File

@ -191,7 +191,7 @@ void AutoDownloadBox::setupContent() {
});
if (changed) {
for (const auto [type, enabled] : values) {
for (const auto &[type, enabled] : values) {
const auto value = enabled ? limitByType(type) : 0;
settings->setBytesLimit(_source, type, value);
}

View File

@ -896,7 +896,7 @@ void ProxyBox::setupTypes() {
{ Type::Socks5, "SOCKS5" },
{ Type::Mtproto, "MTPROTO" },
};
for (const auto [type, label] : types) {
for (const auto &[type, label] : types) {
_content->add(
object_ptr<Ui::Radioenum<Type>>(
_content,

View File

@ -405,7 +405,7 @@ void PasscodeBox::setPasswordFail(
const MTP::Error &error) {
const auto prefix = qstr("EMAIL_UNCONFIRMED_");
if (error.type().startsWith(prefix)) {
const auto codeLength = error.type().mid(prefix.size()).toInt();
const auto codeLength = error.type().midRef(prefix.size()).toInt();
closeReplacedBy();
_setRequest = 0;

View File

@ -431,7 +431,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
_instance->emitJoinPayload([=](tgcalls::GroupJoinPayload payload) {
crl::on_main(weak, [=, payload = std::move(payload)]{
auto fingerprints = QJsonArray();
for (const auto print : payload.fingerprints) {
for (const auto &print : payload.fingerprints) {
auto object = QJsonObject();
object.insert("hash", QString::fromStdString(print.hash));
object.insert("setup", QString::fromStdString(print.setup));

View File

@ -852,7 +852,7 @@ MembersController::MembersController(
if (!(hide && _soundingAnimationHideLastTime)) {
_soundingAnimationHideLastTime = hide ? crl::now() : 0;
}
for (const auto [_, row] : _soundingRowBySsrc) {
for (const auto &[_, row] : _soundingRowBySsrc) {
if (hide) {
updateRowLevel(row, 0.);
}
@ -870,7 +870,7 @@ MembersController::MembersController(
_soundingAnimation.stop();
return false;
}
for (const auto [ssrc, row] : _soundingRowBySsrc) {
for (const auto &[ssrc, row] : _soundingRowBySsrc) {
row->updateBlobAnimation(now);
delegate()->peerListUpdateRow(row);
}

View File

@ -75,7 +75,7 @@ void DicePack::applySet(const MTPDmessages_stickerSet &data) {
if (isSlotMachine) {
return;
}
for (const auto pack : data.vpacks().v) {
for (const auto &pack : data.vpacks().v) {
pack.match([&](const MTPDstickerPack &data) {
const auto emoji = qs(data.vemoticon());
if (emoji.isEmpty()) {

View File

@ -2551,7 +2551,7 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
};
if (cloudCount > 0) {
for (const auto document : cloudIt->second->stickers) {
for (const auto document : std::as_const(cloudIt->second->stickers)) {
add(document, false);
}
}
@ -2559,7 +2559,7 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
add(recentSticker.first, false);
}
if (customCount > 0) {
for (const auto document : customIt->second->stickers) {
for (const auto document : std::as_const(customIt->second->stickers)) {
add(document, true);
}
}

View File

@ -463,7 +463,7 @@ void Launcher::processArguments() {
auto parseResult = QMap<QByteArray, QStringList>();
auto parsingKey = QByteArray();
auto parsingFormat = KeyFormat::NoValues;
for (const auto &argument : _arguments) {
for (const auto &argument : std::as_const(_arguments)) {
switch (parsingFormat) {
case KeyFormat::OneValue: {
parseResult[parsingKey] = QStringList(argument.mid(0, 8192));

View File

@ -259,7 +259,7 @@ void Sandbox::socketReading() {
}
_localSocketReadData.append(_localSocket.readAll());
if (QRegularExpression("RES:(\\d+);").match(_localSocketReadData).hasMatch()) {
uint64 pid = _localSocketReadData.mid(4, _localSocketReadData.length() - 5).toULongLong();
uint64 pid = _localSocketReadData.midRef(4, _localSocketReadData.length() - 5).toULongLong();
if (pid != kEmptyPidForCommandResponse) {
psActivateProcess(pid);
}

View File

@ -830,7 +830,7 @@ void HttpLoaderActor::sendRequest() {
void HttpLoaderActor::gotMetaData() {
const auto pairs = _reply->rawHeaderPairs();
for (const auto pair : pairs) {
for (const auto &pair : pairs) {
if (QString::fromUtf8(pair.first).toLower() == "content-range") {
const auto m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(pair.second));
if (m.hasMatch()) {
@ -979,7 +979,7 @@ auto MtpChecker::parseText(const QByteArray &text) const
return false;
}
bestLocation.username = full.mid(start + 1, post - start - 1);
bestLocation.postId = full.mid(post + 1).toInt();
bestLocation.postId = full.midRef(post + 1).toInt();
if (bestLocation.username.isEmpty() || !bestLocation.postId) {
LOG(("Update Error: MTP entry '%1' is bad for version %2."
).arg(full

View File

@ -511,12 +511,12 @@ void GroupCall::requestUnknownParticipants() {
}();
auto ssrcInputs = QVector<MTPint>();
ssrcInputs.reserve(ssrcs.size());
for (const auto [ssrc, when] : ssrcs) {
for (const auto &[ssrc, when] : ssrcs) {
ssrcInputs.push_back(MTP_int(ssrc));
}
auto peerInputs = QVector<MTPInputPeer>();
peerInputs.reserve(participantPeerIds.size());
for (const auto [participantPeerId, when] : participantPeerIds) {
for (const auto &[participantPeerId, when] : participantPeerIds) {
if (const auto userId = peerToUser(participantPeerId)) {
peerInputs.push_back(
MTP_inputPeerUser(MTP_int(userId), MTP_long(0)));
@ -544,13 +544,13 @@ void GroupCall::requestUnknownParticipants() {
});
_unknownParticipantPeersRequestId = 0;
const auto now = crl::now();
for (const auto [ssrc, when] : ssrcs) {
for (const auto &[ssrc, when] : ssrcs) {
if (when.voice || when.anything) {
applyLastSpoke(ssrc, when, now);
}
_unknownSpokenSsrcs.remove(ssrc);
}
for (const auto [id, when] : participantPeerIds) {
for (const auto &[id, when] : participantPeerIds) {
if (const auto participantPeer = _peer->owner().peerLoaded(id)) {
const auto isParticipant = ranges::contains(
_participants,
@ -565,10 +565,10 @@ void GroupCall::requestUnknownParticipants() {
requestUnknownParticipants();
}).fail([=](const MTP::Error &error) {
_unknownParticipantPeersRequestId = 0;
for (const auto [ssrc, when] : ssrcs) {
for (const auto &[ssrc, when] : ssrcs) {
_unknownSpokenSsrcs.remove(ssrc);
}
for (const auto [participantPeerId, when] : participantPeerIds) {
for (const auto &[participantPeerId, when] : participantPeerIds) {
_unknownSpokenPeerIds.remove(participantPeerId);
}
requestUnknownParticipants();

View File

@ -1896,7 +1896,7 @@ void Session::processMessages(
const auto id = IdFromMessage(message);
indices.emplace((uint64(uint32(id)) << 32) | uint64(i), i);
}
for (const auto [position, index] : indices) {
for (const auto &[position, index] : indices) {
addNewMessage(
data[index],
MTPDmessage_ClientFlags(),

View File

@ -420,7 +420,7 @@ bool Stickers::isFaved(not_null<const DocumentData*> document) {
if (it == sets.cend()) {
return false;
}
for (const auto sticker : it->second->stickers) {
for (const auto sticker : std::as_const(it->second->stickers)) {
if (sticker == document) {
return true;
}
@ -902,7 +902,7 @@ void Stickers::featuredSetsReceived(
if (!setsToRequest.empty()) {
auto &api = session().api();
for (const auto [setId, accessHash] : setsToRequest) {
for (const auto &[setId, accessHash] : setsToRequest) {
api.scheduleStickerSetRequest(setId, accessHash);
}
api.requestStickerSets();

View File

@ -54,7 +54,7 @@ Row *IndexedList::addByName(Key key) {
void IndexedList::adjustByDate(const RowsByLetter &links) {
_list.adjustByDate(links.main);
for (const auto [ch, row] : links.letters) {
for (const auto &[ch, row] : links.letters) {
if (auto it = _index.find(ch); it != _index.cend()) {
it->second.adjustByDate(row);
}

View File

@ -804,7 +804,7 @@ QByteArray HtmlWriter::Wrap::pushGenericListEntry(
result.append(SerializeString(subname));
result.append(popTag());
}
for (const auto detail : details) {
for (const auto &detail : details) {
result.append(pushDiv("details_entry details"));
result.append(SerializeString(detail));
result.append(popTag());

View File

@ -215,7 +215,7 @@ void PanelController::showError(const ApiErrorState &error) {
if (error.data.type() == qstr("TAKEOUT_INVALID")) {
showError(tr::lng_export_invalid(tr::now));
} else if (error.data.type().startsWith(qstr("TAKEOUT_INIT_DELAY_"))) {
const auto seconds = std::max(error.data.type().mid(
const auto seconds = std::max(error.data.type().midRef(
qstr("TAKEOUT_INIT_DELAY_").size()).toInt(), 1);
const auto now = QDateTime::currentDateTime();
const auto when = now.addSecs(seconds);

View File

@ -757,7 +757,7 @@ bool ReplyKeyboard::selectedAnimationCallback(crl::time now) {
}
void ReplyKeyboard::clearSelection() {
for (const auto [relativeIndex, time] : _animations) {
for (const auto &[relativeIndex, time] : _animations) {
const auto index = std::abs(relativeIndex) - 1;
const auto row = (index / MatrixRowShift);
const auto col = index % MatrixRowShift;

View File

@ -1642,7 +1642,7 @@ TextForMimeData ListWidget::getSelectedText() const {
wrapItem(group->items.back(), HistoryGroupText(group));
};
for (const auto [itemId, data] : selected) {
for (const auto &[itemId, data] : selected) {
if (const auto item = session().data().message(itemId)) {
if (const auto group = session().data().groups().find(item)) {
if (groups.contains(group)) {

View File

@ -232,7 +232,7 @@ bool SendActionPainter::updateNeedsAnimating(crl::time now, bool force) {
};
return QString();
};
for (const auto [user, action] : _sendActions) {
for (const auto &[user, action] : _sendActions) {
newTypingString = sendActionString(
action.type,
_history->peer->isUser() ? QString() : user->firstName);

View File

@ -496,7 +496,7 @@ void Widget::resetAccount() {
const auto &type = error.type();
if (type.startsWith(qstr("2FA_CONFIRM_WAIT_"))) {
const auto seconds = type.mid(qstr("2FA_CONFIRM_WAIT_").size()).toInt();
const auto seconds = type.midRef(qstr("2FA_CONFIRM_WAIT_").size()).toInt();
const auto days = (seconds + 59) / 86400;
const auto hours = ((seconds + 59) % 86400) / 3600;
const auto minutes = ((seconds + 59) % 3600) / 60;

View File

@ -384,7 +384,7 @@ void Instance::Private::applyDomainIps(
return true;
}
current.erase(i, end(current));
for (const auto &ip : copy) {
for (const auto &ip : std::as_const(copy)) {
proxy.resolvedIPs.push_back(ip);
}
return true;

View File

@ -1579,7 +1579,7 @@ void Link::initDimensions() {
int32 Link::resizeGetHeight(int32 width) {
_width = qMin(width, _maxw);
int32 w = _width - st::linksPhotoSize - st::linksPhotoPadding;
for (const auto &link : _links) {
for (const auto &link : std::as_const(_links)) {
link.lnk->setFullDisplayed(w >= link.width);
}
@ -1634,7 +1634,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
}
p.setPen(st::windowActiveTextFg);
for (const auto &link : _links) {
for (const auto &link : std::as_const(_links)) {
if (clip.intersects(style::rtlrect(left, top, qMin(w, link.width), st::normalFont->height, _width))) {
p.setFont(ClickHandler::showAsActive(link.lnk) ? st::normalFont->underline() : st::normalFont);
p.drawTextLeft(left, top, _width, (w < link.width) ? st::normalFont->elided(link.text, w) : link.text);

View File

@ -1175,7 +1175,7 @@ void FormController::fillErrors() {
}
}
};
for (const auto &error : _form.pendingErrors) {
for (const auto &error : std::as_const(_form.pendingErrors)) {
error.match([&](const MTPDsecureValueError &data) {
if (const auto value = find(data.vtype())) {
if (CanHaveErrors(value->type)) {
@ -1306,7 +1306,7 @@ void FormController::decryptValue(Value &value) const {
}
const auto fields = DeserializeData(decrypted);
value.data.parsed.fields.clear();
for (const auto [key, text] : fields) {
for (const auto &[key, text] : fields) {
value.data.parsed.fields[key] = { text };
}
}

View File

@ -558,7 +558,7 @@ void PanelEditDocument::updateCommonError() {
void PanelEditDocument::focusInEvent(QFocusEvent *e) {
crl::on_main(this, [=] {
for (const auto [index, row] : _details) {
for (const auto &[index, row] : _details) {
if (row->setFocusFast()) {
return;
}
@ -590,7 +590,7 @@ void PanelEditDocument::updateControlsGeometry() {
PanelEditDocument::Result PanelEditDocument::collect() const {
auto result = Result();
for (const auto [i, field] : _details) {
for (const auto &[i, field] : _details) {
const auto &row = _scheme.rows[i];
auto &fields = (row.valueClass == Scheme::ValueClass::Scans)
? result.filesData
@ -637,7 +637,7 @@ bool PanelEditDocument::validate() {
error = firsttop.y();
}
auto first = QPointer<PanelDetailsRow>();
for (const auto [i, field] : ranges::view::reverse(_details)) {
for (const auto &[i, field] : ranges::view::reverse(_details)) {
const auto &row = _scheme.rows[i];
if (row.valueClass == Scheme::ValueClass::Additional
&& !_additionalShown) {

View File

@ -391,7 +391,7 @@ void WebLoadManager::clear() {
sent.reply->abort();
delete sent.reply;
}
for (const auto reply : base::take(_repliesBeingDeleted)) {
for (const auto &reply : base::take(_repliesBeingDeleted)) {
if (reply) {
delete reply;
}

View File

@ -1578,7 +1578,7 @@ void Account::writeStickerSets(
continue;
}
for (const auto sticker : raw->stickers) {
for (const auto sticker : std::as_const(raw->stickers)) {
size += Serialize::Document::sizeInStream(sticker);
}

View File

@ -576,11 +576,11 @@ QString InterpretSendPath(
auto caption = QString();
for (const auto &line : lines) {
if (line.startsWith(qstr("from: "))) {
if (window->session().userId() != line.mid(qstr("from: ").size()).toInt()) {
if (window->session().userId() != line.midRef(qstr("from: ").size()).toInt()) {
return "App Error: Wrong current user.";
}
} else if (line.startsWith(qstr("channel: "))) {
const auto channelId = line.mid(qstr("channel: ").size()).toInt();
const auto channelId = line.midRef(qstr("channel: ").size()).toInt();
toId = peerFromChannel(channelId);
} else if (line.startsWith(qstr("file: "))) {
const auto path = line.mid(qstr("file: ").size());

View File

@ -204,7 +204,7 @@ void PhonePartInput::onChooseCode(const QString &code) {
_additionalPlaceholder = QString();
if (!_pattern.isEmpty()) {
_additionalPlaceholder.reserve(20);
for (const auto part : _pattern) {
for (const auto part : std::as_const(_pattern)) {
_additionalPlaceholder.append(' ');
_additionalPlaceholder.append(QString(part, QChar(0x2212)));
}

View File

@ -188,7 +188,7 @@ void FiltersMenu::refresh() {
}
_reorder->cancel();
auto now = base::flat_map<int, base::unique_qptr<Ui::SideBarButton>>();
for (const auto filter : filters->list()) {
for (const auto &filter : filters->list()) {
now.emplace(
filter.id(),
prepareButton(

@ -1 +1 @@
Subproject commit 127968de8129e8ccfa6ac50721c70415a5a087c3
Subproject commit a1fc93b134108bbe6081a3f2cb7b17b611655424

@ -1 +1 @@
Subproject commit cbe51722b73cfa9ff27bd59294b08aa5ee33c936
Subproject commit b39d20fe229be82d9c119306136f1f65a1c91e2b

@ -1 +1 @@
Subproject commit 2696dbc959f29b773646d5ba6fc882a2ad468565
Subproject commit 2039c5929359593f0336fb53f585a55c3acd46fd