Skip to content

Commit

Permalink
Replace base::lambda with shorter term.
Browse files Browse the repository at this point in the history
base::lambda -> Fn (type alias for std::function).
base::lambda_once -> FnMut (type alias for base::unique_function).
base::lambda_guarded -> crl::guard.
base::lambda_call_type_t -> crl::deduced_call_type.
  • Loading branch information
john-preston committed Jun 4, 2018
1 parent 8d1cdea commit dd81f5d
Show file tree
Hide file tree
Showing 216 changed files with 792 additions and 1,455 deletions.
20 changes: 10 additions & 10 deletions Telegram/SourceFiles/apiwrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ ApiWrap::ApiWrap(not_null<AuthSession*> session)

void ApiWrap::requestChangelog(
const QString &sinceVersion,
base::lambda<void(const MTPUpdates &result)> callback) {
Fn<void(const MTPUpdates &result)> callback) {
request(MTPhelp_GetAppChangelog(
MTP_string(sinceVersion)
)).done(
Expand Down Expand Up @@ -235,7 +235,7 @@ void ApiWrap::proxyPromotionDone(const MTPhelp_ProxyData &proxy) {

void ApiWrap::requestDeepLinkInfo(
const QString &path,
base::lambda<void(const MTPDhelp_deepLinkInfo &result)> callback) {
Fn<void(const MTPDhelp_deepLinkInfo &result)> callback) {
request(_deepLinkInfoRequestId).cancel();
_deepLinkInfoRequestId = request(MTPhelp_GetDeepLinkInfo(
MTP_string(path)
Expand Down Expand Up @@ -276,7 +276,7 @@ void ApiWrap::savePinnedOrder() {
//void ApiWrap::toggleChannelGrouping(
// not_null<ChannelData*> channel,
// bool group,
// base::lambda<void()> callback) {
// Fn<void()> callback) {
// if (const auto already = _channelGroupingRequests.take(channel)) {
// request(already->first).cancel();
// }
Expand Down Expand Up @@ -1419,7 +1419,7 @@ void ApiWrap::deleteAllFromUserSend(

void ApiWrap::requestChannelMembersForAdd(
not_null<ChannelData*> channel,
base::lambda<void(const MTPchannels_ChannelParticipants&)> callback) {
Fn<void(const MTPchannels_ChannelParticipants&)> callback) {
_channelMembersForAddCallback = std::move(callback);
if (_channelMembersForAdd == channel) {
return;
Expand Down Expand Up @@ -2617,10 +2617,10 @@ void ApiWrap::readFeaturedSets() {
void ApiWrap::parseChannelParticipants(
not_null<ChannelData*> channel,
const MTPchannels_ChannelParticipants &result,
base::lambda<void(
Fn<void(
int availableCount,
const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified) {
Fn<void()> callbackNotModified) {
TLHelp::VisitChannelParticipants(result, base::overload([&](
const MTPDchannels_channelParticipants &data) {
App::feedUsers(data.vusers);
Expand Down Expand Up @@ -2654,10 +2654,10 @@ void ApiWrap::refreshChannelAdmins(
void ApiWrap::parseRecentChannelParticipants(
not_null<ChannelData*> channel,
const MTPchannels_ChannelParticipants &result,
base::lambda<void(
Fn<void(
int availableCount,
const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified) {
Fn<void()> callbackNotModified) {
parseChannelParticipants(channel, result, [&](
int availableCount,
const QVector<MTPChannelParticipant> &list) {
Expand Down Expand Up @@ -3536,12 +3536,12 @@ void ApiWrap::sendAction(const SendOptions &options) {
void ApiWrap::forwardMessages(
HistoryItemsList &&items,
const SendOptions &options,
base::lambda_once<void()> &&successCallback) {
FnMut<void()> &&successCallback) {
Expects(!items.empty());

struct SharedCallback {
int requestsLeft = 0;
base::lambda_once<void()> callback;
FnMut<void()> callback;
};
const auto shared = successCallback
? std::make_shared<SharedCallback>()
Expand Down
24 changes: 12 additions & 12 deletions Telegram/SourceFiles/apiwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {
//void toggleChannelGrouping( // #feed
// not_null<ChannelData*> channel,
// bool group,
// base::lambda<void()> callback);
// Fn<void()> callback);
//void ungroupAllFromFeed(not_null<Data::Feed*> feed);

using RequestMessageDataCallback = base::lambda<void(ChannelData*, MsgId)>;
using RequestMessageDataCallback = Fn<void(ChannelData*, MsgId)>;
void requestMessageData(
ChannelData *channel,
MsgId msgId,
Expand All @@ -92,15 +92,15 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {

void requestChangelog(
const QString &sinceVersion,
base::lambda<void(const MTPUpdates &result)> callback);
Fn<void(const MTPUpdates &result)> callback);
void refreshProxyPromotion();
void requestDeepLinkInfo(
const QString &path,
base::lambda<void(const MTPDhelp_deepLinkInfo &result)> callback);
Fn<void(const MTPDhelp_deepLinkInfo &result)> callback);

void requestChannelMembersForAdd(
not_null<ChannelData*> channel,
base::lambda<void(const MTPchannels_ChannelParticipants&)> callback);
Fn<void(const MTPchannels_ChannelParticipants&)> callback);
void processFullPeer(PeerData *peer, const MTPmessages_ChatFull &result);
void processFullPeer(UserData *user, const MTPUserFull &result);

Expand Down Expand Up @@ -206,17 +206,17 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {
void parseChannelParticipants(
not_null<ChannelData*> channel,
const MTPchannels_ChannelParticipants &result,
base::lambda<void(
Fn<void(
int availableCount,
const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified = nullptr);
Fn<void()> callbackNotModified = nullptr);
void parseRecentChannelParticipants(
not_null<ChannelData*> channel,
const MTPchannels_ChannelParticipants &result,
base::lambda<void(
Fn<void(
int availableCount,
const QVector<MTPChannelParticipant> &list)> callbackList,
base::lambda<void()> callbackNotModified = nullptr);
Fn<void()> callbackNotModified = nullptr);

struct SendOptions {
SendOptions(not_null<History*> history) : history(history) {
Expand All @@ -235,7 +235,7 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {
void forwardMessages(
HistoryItemsList &&items,
const SendOptions &options,
base::lambda_once<void()> &&successCallback = nullptr);
FnMut<void()> &&successCallback = nullptr);
void shareContact(
const QString &phone,
const QString &firstName,
Expand Down Expand Up @@ -462,11 +462,11 @@ class ApiWrap : private MTP::Sender, private base::Subscriber {

ChannelData *_channelMembersForAdd = nullptr;
mtpRequestId _channelMembersForAddRequestId = 0;
base::lambda<void(
Fn<void(
const MTPchannels_ChannelParticipants&)> _channelMembersForAddCallback;
base::flat_map<
not_null<ChannelData*>,
std::pair<mtpRequestId,base::lambda<void()>>> _channelGroupingRequests;
std::pair<mtpRequestId,Fn<void()>>> _channelGroupingRequests;

using KickRequest = std::pair<
not_null<ChannelData*>,
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ namespace {
return i.value();
}

void enumerateUsers(base::lambda<void(not_null<UserData*>)> action) {
void enumerateUsers(Fn<void(not_null<UserData*>)> action) {
for_const (const auto peer, peersData) {
if (const auto user = peer->asUser()) {
action(user);
Expand All @@ -1159,7 +1159,7 @@ namespace {
}

void enumerateChatsChannels(
base::lambda<void(not_null<PeerData*>)> action) {
Fn<void(not_null<PeerData*>)> action) {
for_const (const auto peer, peersData) {
if (!peer->isUser()) {
action(peer);
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ namespace App {
inline ChannelData *channelLoaded(ChannelId channelId) {
return channel(channelId, PeerData::FullLoaded);
}
void enumerateUsers(base::lambda<void(not_null<UserData*>)> action);
void enumerateUsers(Fn<void(not_null<UserData*>)> action);
void enumerateChatsChannels(
base::lambda<void(not_null<PeerData*>)> action);
Fn<void(not_null<PeerData*>)> action);

UserData *self();
PeerData *peerByName(const QString &username);
Expand Down
Loading

0 comments on commit dd81f5d

Please sign in to comment.