replace variant with var

https://doc.qt.io/archives/qt-5.6/qtquick-performance.html
In general, "property var" should be considered to be superior to "property variant" for every use-case from QtQuick 2.0 and newer (note that "property variant" is marked as obsolete), as it allows a true JavaScript reference to be stored (which can reduce the number of conversions required in certain expressions).
This commit is contained in:
John Gibbon 2020-11-05 23:23:37 +01:00
parent 5a9ecd03cc
commit fdb8cc5852
19 changed files with 42 additions and 42 deletions

View file

@ -25,9 +25,9 @@ Item {
id: audioMessageComponent id: audioMessageComponent
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property variant audioData: ( rawMessage.content['@type'] === "messageVoiceNote" ) ? rawMessage.content.voice_note : ( ( rawMessage.content['@type'] === "messageAudio" ) ? rawMessage.content.audio : ""); property var audioData: ( rawMessage.content['@type'] === "messageVoiceNote" ) ? rawMessage.content.voice_note : ( ( rawMessage.content['@type'] === "messageAudio" ) ? rawMessage.content.audio : "");
property string audioUrl; property string audioUrl;
property int previewFileId; property int previewFileId;
property int audioFileId; property int audioFileId;

View file

@ -26,9 +26,9 @@ Item {
height: Theme.itemSizeLarge height: Theme.itemSizeLarge
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property variant documentData: rawMessage.content.document property var documentData: rawMessage.content.document
property bool openRequested: false; property bool openRequested: false;
Component.onCompleted: { Component.onCompleted: {

View file

@ -24,9 +24,9 @@ Item {
id: imagePreviewItem id: imagePreviewItem
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property variant photoData: rawMessage.content.photo; property var photoData: rawMessage.content.photo;
property variant pictureFileInformation; property var pictureFileInformation;
width: parent.width width: parent.width
height: width * 2 / 3 height: width * 2 / 3

View file

@ -29,7 +29,7 @@ Row {
height: inReplyToMessageColumn.height height: inReplyToMessageColumn.height
property string myUserId; property string myUserId;
property variant inReplyToMessage; property var inReplyToMessage;
property bool editable: false; property bool editable: false;
signal clearRequested() signal clearRequested()

View file

@ -25,12 +25,12 @@ Item {
id: imagePreviewItem id: imagePreviewItem
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property variant locationData : ( rawMessage.content['@type'] === "messageLocation" ) ? rawMessage.content.location : ( ( rawMessage.content['@type'] === "messageVenue" ) ? rawMessage.content.venue.location : "" ) property var locationData : ( rawMessage.content['@type'] === "messageLocation" ) ? rawMessage.content.location : ( ( rawMessage.content['@type'] === "messageVenue" ) ? rawMessage.content.venue.location : "" )
property string chatId: messageListItem.page.chatInformation.id property string chatId: messageListItem.page.chatInformation.id
property variant pictureFileInformation; property var pictureFileInformation;
width: parent.width width: parent.width
height: width / 2 height: width / 2

View file

@ -24,8 +24,8 @@ import "../js/functions.js" as Functions
ListItem { ListItem {
id: messageListItem id: messageListItem
contentHeight: messageBackground.height + Theme.paddingMedium contentHeight: messageBackground.height + Theme.paddingMedium
property variant myMessage: display property var myMessage: display
property variant userInformation: tdLibWrapper.getUserInformation(display.sender_user_id) property var userInformation: tdLibWrapper.getUserInformation(display.sender_user_id)
property Page page: chatPage property Page page: chatPage
property bool isOwnMessage: chatPage.myUserId === display.sender_user_id property bool isOwnMessage: chatPage.myUserId === display.sender_user_id

View file

@ -23,8 +23,8 @@ import "../js/functions.js" as Functions
Item { Item {
id: messageListItem id: messageListItem
property variant myMessage: display property var myMessage: display
property variant userInformation: tdLibWrapper.getUserInformation(myMessage.sender_user_id) property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender_user_id)
property bool isOwnMessage: chatPage.myUserId === myMessage.sender_user_id property bool isOwnMessage: chatPage.myUserId === myMessage.sender_user_id
height: backgroundRectangle.height + Theme.paddingMedium height: backgroundRectangle.height + Theme.paddingMedium

View file

@ -28,7 +28,7 @@ Item {
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property string chatId: messageListItem.page.chatInformation.id property string chatId: messageListItem.page.chatInformation.id
property bool isOwnMessage: messageListItem.isOwnMessage property bool isOwnMessage: messageListItem.isOwnMessage

View file

@ -24,7 +24,7 @@ Item {
id: profileThumbnail id: profileThumbnail
property variant photoData; property var photoData;
property string replacementStringHint: "X" property string replacementStringHint: "X"
property bool forceElementUpdate: false property bool forceElementUpdate: false
property int radius: width / 2 property int radius: width / 2

View file

@ -25,8 +25,8 @@ Item {
id: stickerPickerOverlayItem id: stickerPickerOverlayItem
anchors.fill: parent anchors.fill: parent
property variant recentStickers: stickerManager.getRecentStickers() property var recentStickers: stickerManager.getRecentStickers()
property variant installedStickerSets: stickerManager.getInstalledStickerSets() property var installedStickerSets: stickerManager.getInstalledStickerSets()
property bool pickerLoaded: false property bool pickerLoaded: false
Timer { Timer {

View file

@ -22,9 +22,9 @@ import Sailfish.Silica 1.0
Item { Item {
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property variant stickerData: rawMessage.content.sticker; property var stickerData: rawMessage.content.sticker;
property int usedFileId; property int usedFileId;
width: stickerData.width width: stickerData.width

View file

@ -25,9 +25,9 @@ Item {
id: videoMessageComponent id: videoMessageComponent
property ListItem messageListItem property ListItem messageListItem
property variant rawMessage: messageListItem.myMessage property var rawMessage: messageListItem.myMessage
property variant videoData: ( rawMessage.content['@type'] === "messageVideo" ) ? rawMessage.content.video : ( ( rawMessage.content['@type'] === "messageAnimation" ) ? rawMessage.content.animation : "") property var videoData: ( rawMessage.content['@type'] === "messageVideo" ) ? rawMessage.content.video : ( ( rawMessage.content['@type'] === "messageAnimation" ) ? rawMessage.content.animation : "")
property string videoUrl; property string videoUrl;
property int previewFileId; property int previewFileId;
property int videoFileId; property int videoFileId;

View file

@ -27,8 +27,8 @@ Column {
id: webPagePreviewColumn id: webPagePreviewColumn
property variant webPageData; property var webPageData;
property variant pictureFileInformation; property var pictureFileInformation;
property bool hasImage: false; property bool hasImage: false;
spacing: Theme.paddingSmall spacing: Theme.paddingSmall

View file

@ -33,7 +33,7 @@ ChatInformationTabItemBase {
loading: ( chatInformationPage.isSuperGroup || chatInformationPage.isPrivateChat) && !chatInformationPage.isChannel loading: ( chatInformationPage.isSuperGroup || chatInformationPage.isPrivateChat) && !chatInformationPage.isChannel
loadingVisible: loading && membersView.count === 0 loadingVisible: loading && membersView.count === 0
property variant chatPartnerCommonGroupsIds: ([]); property var chatPartnerCommonGroupsIds: ([]);
SilicaListView { SilicaListView {
id: membersView id: membersView

View file

@ -26,7 +26,7 @@ Page {
id: aboutPage id: aboutPage
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
property variant userInformation : tdLibWrapper.getUserInformation(); property var userInformation : tdLibWrapper.getUserInformation();
SilicaFlickable { SilicaFlickable {
id: aboutContainer id: aboutContainer

View file

@ -29,12 +29,12 @@ Page {
|| (groupInformation.status["@type"] === "chatMemberStatusCreator" && groupInformation.status.is_member) || (groupInformation.status["@type"] === "chatMemberStatusCreator" && groupInformation.status.is_member)
) )
property variant chatInformation:({}); property var chatInformation:({});
property variant privateChatUserInformation:({}); property var privateChatUserInformation:({});
property variant chatPartnerFullInformation:({}); property var chatPartnerFullInformation:({});
property variant chatPartnerProfilePhotos:([]); property var chatPartnerProfilePhotos:([]);
property variant groupInformation: ({}); property var groupInformation: ({});
property variant groupFullInformation: ({}); property var groupFullInformation: ({});
property alias membersList: membersList property alias membersList: membersList

View file

@ -33,15 +33,15 @@ Page {
property bool loading: true; property bool loading: true;
property bool isInitialized: false; property bool isInitialized: false;
property int myUserId: tdLibWrapper.getUserInformation().id; property int myUserId: tdLibWrapper.getUserInformation().id;
property variant chatInformation; property var chatInformation;
property bool isPrivateChat: false; property bool isPrivateChat: false;
property bool isBasicGroup: false; property bool isBasicGroup: false;
property bool isSuperGroup: false; property bool isSuperGroup: false;
property bool isChannel: false; property bool isChannel: false;
property variant chatPartnerInformation; property var chatPartnerInformation;
property variant chatGroupInformation; property var chatGroupInformation;
property int chatOnlineMemberCount: 0; property int chatOnlineMemberCount: 0;
property variant emojiProposals; property var emojiProposals;
function updateChatPartnerStatusText() { function updateChatPartnerStatusText() {
var statusText = Functions.getChatPartnerStatusText(chatPartnerInformation.status['@type'], chatPartnerInformation.status.was_online); var statusText = Functions.getChatPartnerStatusText(chatPartnerInformation.status['@type'], chatPartnerInformation.status.was_online);
@ -543,7 +543,7 @@ Page {
} }
model: chatModel model: chatModel
property variant contentComponentNames: ({ property var contentComponentNames: ({
messageSticker: "StickerPreview", messageSticker: "StickerPreview",
messagePhoto: "ImagePreview", messagePhoto: "ImagePreview",
messageVideo: "VideoPreview", messageVideo: "VideoPreview",
@ -784,7 +784,7 @@ Page {
property bool isPicture: false; property bool isPicture: false;
property bool isVideo: false; property bool isVideo: false;
property bool isDocument: false; property bool isDocument: false;
property variant fileProperties:({}); property var fileProperties:({});
IconButton { IconButton {
id: removeAttachmentsIconButton id: removeAttachmentsIconButton

View file

@ -26,8 +26,8 @@ Page {
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
backNavigation: !imageOnly backNavigation: !imageOnly
property variant photoData; property var photoData;
property variant pictureFileInformation; property var pictureFileInformation;
property string imageUrl; property string imageUrl;
property int imageWidth; property int imageWidth;

View file

@ -26,7 +26,7 @@ Page {
id: videoPage id: videoPage
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
property variant videoData; property var videoData;
property int videoWidth : videoData.width property int videoWidth : videoData.width
property int videoHeight : videoData.height property int videoHeight : videoData.height