Don't pass primitive data as a const reference

It just doesn't make any sense.

Reference (essentially a pointer) can't be smaller than a primitive
type, except for 64-bit numbers on a 32-bit platform. In terms of
performance, an additional indirection can't be better than picking
the value directly from the stack, let alone a register.
This commit is contained in:
Slava Monich 2020-10-24 02:05:49 +03:00
parent 5d14d9b000
commit 460eaa878f
4 changed files with 45 additions and 45 deletions

View file

@ -118,7 +118,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren
handlers.insert("updateChatTitle", &TDLibReceiver::processUpdateChatTitle);
}
void TDLibReceiver::setActive(const bool &active)
void TDLibReceiver::setActive(bool active)
{
if (active) {
LOG("Activating receiver loop...");

View file

@ -33,7 +33,7 @@ class TDLibReceiver : public QThread
}
public:
explicit TDLibReceiver(void *tdLibClient, QObject *parent = nullptr);
void setActive(const bool &active);
void setActive(bool active);
signals:
void versionDetected(const QString &version);
@ -48,12 +48,12 @@ signals:
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
void chatOrderUpdated(const QString &chatId, const QString &order);
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, const int &unreadCount);
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
void basicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
void superGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
void chatOnlineMemberCountUpdated(const QString &chatId, const int &onlineMemberCount);
void messagesReceived(const QVariantList &messages, const int &totalCount);
void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount);
void messagesReceived(const QVariantList &messages, int totalCount);
void newMessageReceived(const QString &chatId, const QVariantMap &message);
void messageInformation(const QString &messageId, const QVariantMap &message);
void messageSendSucceeded(const QString &messageId, const QString &oldMessageId, const QVariantMap &message);
@ -70,14 +70,14 @@ signals:
void installedStickerSetsUpdated(const QVariantList &stickerSetIds);
void stickerSets(const QVariantList &stickerSets);
void stickerSet(const QVariantMap &stickerSet);
void chatMembers(const QString &extra, const QVariantList &members, const int &totalMembers);
void chatMembers(const QString &extra, const QVariantList &members, int totalMembers);
void userFullInfo(const QVariantMap &userFullInfo);
void userFullInfoUpdated(const QString &userId,const QVariantMap &userFullInfo);
void basicGroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
void basicGroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void supergroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
void supergroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void userProfilePhotos(const QString &extra, const QVariantList &photos, const int &totalPhotos);
void userProfilePhotos(const QString &extra, const QVariantList &photos, int totalPhotos);
void chatPermissionsUpdated(const QString &chatId, const QVariantMap &chatPermissions);
void chatTitleUpdated(const QString &chatId, const QString &title);
private:

View file

@ -245,7 +245,7 @@ void TDLibWrapper::leaveChat(const QString &chatId)
this->sendRequest(requestObject);
}
void TDLibWrapper::getChatHistory(const QString &chatId, const qlonglong &fromMessageId, const int &offset, const int &limit, const bool &onlyLocal)
void TDLibWrapper::getChatHistory(const QString &chatId, const qlonglong &fromMessageId, int offset, int limit, bool onlyLocal)
{
LOG("Retrieving chat history" << chatId << fromMessageId << offset << limit << onlyLocal);
QVariantMap requestObject;
@ -258,7 +258,7 @@ void TDLibWrapper::getChatHistory(const QString &chatId, const qlonglong &fromMe
this->sendRequest(requestObject);
}
void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId, const bool &force = false)
void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId, bool force)
{
LOG("Mark message as viewed" << chatId << messageId);
QVariantMap requestObject;
@ -394,7 +394,7 @@ void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId)
this->sendRequest(requestObject);
}
void TDLibWrapper::setOptionInteger(const QString &optionName, const int &optionValue)
void TDLibWrapper::setOptionInteger(const QString &optionName, int optionValue)
{
LOG("Setting integer option" << optionName << optionValue);
QVariantMap requestObject;
@ -444,7 +444,7 @@ void TDLibWrapper::deleteMessages(const QString &chatId, const QVariantList mess
this->sendRequest(requestObject);
}
void TDLibWrapper::getMapThumbnailFile(const QString &chatId, const double &latitude, const double &longitude, const int &width, const int &height)
void TDLibWrapper::getMapThumbnailFile(const QString &chatId, double latitude, double longitude, int width, int height)
{
LOG("Getting Map Thumbnail File" << chatId);
QVariantMap location;
@ -491,7 +491,7 @@ void TDLibWrapper::getStickerSet(const QString &setId)
requestObject.insert("set_id", setId);
this->sendRequest(requestObject);
}
void TDLibWrapper::getSupergroupMembers(const QString &groupId, const int &limit = 200, const int &offset = 0)
void TDLibWrapper::getSupergroupMembers(const QString &groupId, int limit, int offset)
{
LOG("Retrieving SupergroupMembers");
QVariantMap requestObject;
@ -503,7 +503,7 @@ void TDLibWrapper::getSupergroupMembers(const QString &groupId, const int &limit
this->sendRequest(requestObject);
}
void TDLibWrapper::getGroupFullInfo(const QString &groupId, const bool &isSuperGroup)
void TDLibWrapper::getGroupFullInfo(const QString &groupId, bool isSuperGroup)
{
LOG("Retrieving GroupFullInfo");
QVariantMap requestObject;
@ -538,7 +538,7 @@ void TDLibWrapper::createPrivateChat(const QString &userId)
this->sendRequest(requestObject);
}
void TDLibWrapper::getGroupsInCommon(const QString &userId, const int &limit, const int &offset)
void TDLibWrapper::getGroupsInCommon(const QString &userId, int limit, int offset)
{
LOG("Retrieving Groups in Common");
QVariantMap requestObject;
@ -550,7 +550,7 @@ void TDLibWrapper::getGroupsInCommon(const QString &userId, const int &limit, co
this->sendRequest(requestObject);
}
void TDLibWrapper::getUserProfilePhotos(const QString &userId, const int &limit, const int &offset)
void TDLibWrapper::getUserProfilePhotos(const QString &userId, int limit, int offset)
{
LOG("Retrieving User Profile Photos");
QVariantMap requestObject;
@ -573,7 +573,7 @@ void TDLibWrapper::setChatPermissions(const QString &chatId, const QVariantMap &
this->sendRequest(requestObject);
}
void TDLibWrapper::setChatSlowModeDelay(const QString &chatId, const int &delay)
void TDLibWrapper::setChatSlowModeDelay(const QString &chatId, int delay)
{
LOG("Setting Chat Slow Mode Delay");
@ -613,7 +613,7 @@ void TDLibWrapper::setBio(const QString &bio)
this->sendRequest(requestObject);
}
void TDLibWrapper::toggleSupergroupIsAllHistoryAvailable(const QString &groupId, const bool &isAllHistoryAvailable)
void TDLibWrapper::toggleSupergroupIsAllHistoryAvailable(const QString &groupId, bool isAllHistoryAvailable)
{
LOG("Toggling SupergroupIsAllHistoryAvailable");
QVariantMap requestObject;
@ -717,7 +717,7 @@ void TDLibWrapper::openFileOnDevice(const QString &filePath)
}
}
void TDLibWrapper::controlScreenSaver(const bool &enabled)
void TDLibWrapper::controlScreenSaver(bool enabled)
{
LOG("Controlling device screen saver" << enabled);
QDBusConnection dbusConnection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system");
@ -888,7 +888,7 @@ void TDLibWrapper::handleChatOrderUpdated(const QString &chatId, const QString &
emit chatOrderUpdated(chatId, order);
}
void TDLibWrapper::handleChatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, const int &unreadCount)
void TDLibWrapper::handleChatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount)
{
emit chatReadInboxUpdated(chatId, lastReadInboxMessageId, unreadCount);
}
@ -908,12 +908,12 @@ void TDLibWrapper::handleSuperGroupUpdated(qlonglong groupId, const QVariantMap
emit superGroupUpdated(updateGroup(groupId, groupInformation, &superGroups)->groupId);
}
void TDLibWrapper::handleChatOnlineMemberCountUpdated(const QString &chatId, const int &onlineMemberCount)
void TDLibWrapper::handleChatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount)
{
emit chatOnlineMemberCountUpdated(chatId, onlineMemberCount);
}
void TDLibWrapper::handleMessagesReceived(const QVariantList &messages, const int &totalCount)
void TDLibWrapper::handleMessagesReceived(const QVariantList &messages, int totalCount)
{
emit messagesReceived(messages, totalCount);
}
@ -1009,7 +1009,7 @@ void TDLibWrapper::handleEmojiSearchCompleted(const QString &queryString, const
emit emojiSearchSuccessful(resultList);
}
void TDLibWrapper::handleChatMembers(const QString &extra, const QVariantList &members, const int &totalMembers)
void TDLibWrapper::handleChatMembers(const QString &extra, const QVariantList &members, int totalMembers)
{
emit this->chatMembersReceived(extra, members, totalMembers);
}
@ -1044,7 +1044,7 @@ void TDLibWrapper::handleSupergroupFullInfoUpdated(const QString &groupId, const
emit this->supergroupFullInfoUpdated(groupId, groupFullInfo);
}
void TDLibWrapper::handleUserProfilePhotos(const QString &extra, const QVariantList &photos, const int &totalPhotos)
void TDLibWrapper::handleUserProfilePhotos(const QString &extra, const QVariantList &photos, int totalPhotos)
{
emit this->userProfilePhotosReceived(extra, photos, totalPhotos);
}

View file

@ -99,7 +99,7 @@ public:
Q_INVOKABLE QVariantMap getChat(const QString &chatId);
Q_INVOKABLE void copyFileToDownloads(const QString &filePath);
Q_INVOKABLE void openFileOnDevice(const QString &filePath);
Q_INVOKABLE void controlScreenSaver(const bool &enabled);
Q_INVOKABLE void controlScreenSaver(bool enabled);
DBusAdaptor *getDBusAdaptor();
@ -114,34 +114,34 @@ public:
Q_INVOKABLE void openChat(const QString &chatId);
Q_INVOKABLE void closeChat(const QString &chatId);
Q_INVOKABLE void leaveChat(const QString &chatId);
Q_INVOKABLE void getChatHistory(const QString &chatId, const qlonglong &fromMessageId = 0, const int &offset = 0, const int &limit = 50, const bool &onlyLocal = false);
Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId, const bool &force);
Q_INVOKABLE void getChatHistory(const QString &chatId, const qlonglong &fromMessageId = 0, int offset = 0, int limit = 50, bool onlyLocal = false);
Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId, bool force);
Q_INVOKABLE void sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendDocumentMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId = "0");
Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId);
Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue);
Q_INVOKABLE void setOptionInteger(const QString &optionName, int optionValue);
Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings);
Q_INVOKABLE void editMessageText(const QString &chatId, const QString &messageId, const QString &message);
Q_INVOKABLE void deleteMessages(const QString &chatId, const QVariantList messageIds);
Q_INVOKABLE void getMapThumbnailFile(const QString &chatId, const double &latitude, const double &longitude, const int &width, const int &height);
Q_INVOKABLE void getMapThumbnailFile(const QString &chatId, double latitude, double longitude, int width, int height);
Q_INVOKABLE void getRecentStickers();
Q_INVOKABLE void getInstalledStickerSets();
Q_INVOKABLE void getStickerSet(const QString &setId);
Q_INVOKABLE void getSupergroupMembers(const QString &groupId, const int &limit, const int &offset);
Q_INVOKABLE void getGroupFullInfo(const QString &groupId, const bool &isSuperGroup);
Q_INVOKABLE void getSupergroupMembers(const QString &groupId, int limit, int offset);
Q_INVOKABLE void getGroupFullInfo(const QString &groupId, bool isSuperGroup);
Q_INVOKABLE void getUserFullInfo(const QString &userId);
Q_INVOKABLE void createPrivateChat(const QString &userId);
Q_INVOKABLE void getGroupsInCommon(const QString &userId, const int &limit, const int &offset);
Q_INVOKABLE void getUserProfilePhotos(const QString &userId, const int &limit, const int &offset);
Q_INVOKABLE void getGroupsInCommon(const QString &userId, int limit, int offset);
Q_INVOKABLE void getUserProfilePhotos(const QString &userId, int limit, int offset);
Q_INVOKABLE void setChatPermissions(const QString &chatId, const QVariantMap &chatPermissions);
Q_INVOKABLE void setChatSlowModeDelay(const QString &chatId, const int &delay);
Q_INVOKABLE void setChatSlowModeDelay(const QString &chatId, int delay);
Q_INVOKABLE void setChatDescription(const QString &chatId, const QString &description);
Q_INVOKABLE void setChatTitle(const QString &chatId, const QString &title);
Q_INVOKABLE void setBio(const QString &bio);
Q_INVOKABLE void toggleSupergroupIsAllHistoryAvailable(const QString &groupId, const bool &isAllHistoryAvailable);
Q_INVOKABLE void toggleSupergroupIsAllHistoryAvailable(const QString &groupId, bool isAllHistoryAvailable);
// Others (candidates for extraction ;))
Q_INVOKABLE void searchEmoji(const QString &queryString);
@ -156,19 +156,19 @@ signals:
void authorizationStateChanged(const TDLibWrapper::AuthorizationState &authorizationState, const QVariantMap &authorizationStateData);
void optionUpdated(const QString &optionName, const QVariant &optionValue);
void connectionStateChanged(const TDLibWrapper::ConnectionState &connectionState);
void fileUpdated(const int fileId, const QVariantMap &fileInformation);
void fileUpdated(int fileId, const QVariantMap &fileInformation);
void newChatDiscovered(const QString &chatId, const QVariantMap &chatInformation);
void unreadMessageCountUpdated(const QVariantMap &messageCountInformation);
void unreadChatCountUpdated(const QVariantMap &chatCountInformation);
void chatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
void chatOrderUpdated(const QString &chatId, const QString &order);
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, const int &unreadCount);
void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
void userUpdated(const QString &userId, const QVariantMap &userInformation);
void basicGroupUpdated(qlonglong groupId);
void superGroupUpdated(qlonglong groupId);
void chatOnlineMemberCountUpdated(const QString &chatId, const int &onlineMemberCount);
void messagesReceived(const QVariantList &messages, const int &totalCount);
void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount);
void messagesReceived(const QVariantList &messages, int totalCount);
void newMessageReceived(const QString &chatId, const QVariantMap &message);
void copyToDownloadsSuccessful(const QString &fileName, const QString &filePath);
void copyToDownloadsError(const QString &fileName, const QString &filePath);
@ -188,14 +188,14 @@ signals:
void stickerSetsReceived(const QVariantList &stickerSets);
void stickerSetReceived(const QVariantMap &stickerSet);
void emojiSearchSuccessful(const QVariantList &result);
void chatMembersReceived(const QString &extra, const QVariantList &members, const int &totalMembers);
void chatMembersReceived(const QString &extra, const QVariantList &members, int totalMembers);
void userFullInfoReceived(const QVariantMap &userFullInfo);
void userFullInfoUpdated(const QString &userId, const QVariantMap &userFullInfo);
void basicGroupFullInfoReceived(const QString &groupId, const QVariantMap &groupFullInfo);
void supergroupFullInfoReceived(const QString &groupId, const QVariantMap &groupFullInfo);
void basicGroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void supergroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void userProfilePhotosReceived(const QString &extra, const QVariantList &photos, const int &totalPhotos);
void userProfilePhotosReceived(const QString &extra, const QVariantList &photos, int totalPhotos);
void chatPermissionsUpdated(const QString &chatId, const QVariantMap &permissions);
void chatTitleUpdated(const QString &chatId, const QString &title);
@ -212,12 +212,12 @@ public slots:
void handleUnreadChatCountUpdated(const QVariantMap &chatCountInformation);
void handleChatLastMessageUpdated(const QString &chatId, const QString &order, const QVariantMap &lastMessage);
void handleChatOrderUpdated(const QString &chatId, const QString &order);
void handleChatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, const int &unreadCount);
void handleChatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount);
void handleChatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId);
void handleBasicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
void handleSuperGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation);
void handleChatOnlineMemberCountUpdated(const QString &chatId, const int &onlineMemberCount);
void handleMessagesReceived(const QVariantList &messages, const int &totalCount);
void handleChatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount);
void handleMessagesReceived(const QVariantList &messages, int totalCount);
void handleNewMessageReceived(const QString &chatId, const QVariantMap &message);
void handleMessageInformation(const QString &messageId, const QVariantMap &message);
void handleMessageSendSucceeded(const QString &messageId, const QString &oldMessageId, const QVariantMap &message);
@ -235,14 +235,14 @@ public slots:
void handleStickerSets(const QVariantList &stickerSets);
void handleStickerSet(const QVariantMap &stickerSet);
void handleEmojiSearchCompleted(const QString &queryString, const QVariantList &resultList);
void handleChatMembers(const QString &extra, const QVariantList &members, const int &totalMembers);
void handleChatMembers(const QString &extra, const QVariantList &members, int totalMembers);
void handleUserFullInfo(const QVariantMap &userFullInfo);
void handleUserFullInfoUpdated(const QString &userId, const QVariantMap &userFullInfo);
void handleBasicGroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
void handleBasicGroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void handleSupergroupFullInfo(const QString &groupId, const QVariantMap &groupFullInfo);
void handleSupergroupFullInfoUpdated(const QString &groupId, const QVariantMap &groupFullInfo);
void handleUserProfilePhotos(const QString &extra, const QVariantList &photos, const int &totalPhotos);
void handleUserProfilePhotos(const QString &extra, const QVariantList &photos, int totalPhotos);
void handleChatPermissionsUpdated(const QString &chatId, const QVariantMap permissions);
void handleChatTitleUpdated(const QString &chatId, const QString title);