Skip to content

Commit

Permalink
perf(chatScroll): Improve performance of the commonly used js libraries
Browse files Browse the repository at this point in the history
Adding .pragma library to the js libraries because the entry point on these libraries were called multiple times. There is no need to share the qml context with these libraries.
Use find() instead of forEach() on emoji array to find an item
  • Loading branch information
alexjba committed Jan 19, 2023
1 parent 7adcbeb commit 15fe97c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ui/StatusQ/src/StatusQ/Core/Utils/Emoji.qml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ QtObject {
return value.match(/<img class=\"emoji\" draggable=\"false\" alt=\"(.+?)\" src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g, "$1");
}
function getEmojiUnicode(shortname) {
var _emoji;
EmojiJSON.emoji_json.forEach(function(emoji) {
if (emoji.shortname === shortname)
_emoji = emoji;

const _emoji = EmojiJSON.emoji_json.find(function(emoji) {
return (emoji.shortname === shortname)
})

if (_emoji !== undefined)
Expand Down
2 changes: 2 additions & 0 deletions ui/StatusQ/src/StatusQ/Core/Utils/emojiList.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.pragma library

var emojiCategories = [
"time",
"smileys-and-people",
Expand Down
1 change: 1 addition & 0 deletions ui/StatusQ/src/StatusQ/Core/Utils/xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Most this code was copied from https://github.com/leizongmin/js-xss and slightly modifed
* to work with JavaScript resource loading in QML.
*/
.pragma library

var defaultCSSFilter = new FilterCSS();

Expand Down

0 comments on commit 15fe97c

Please sign in to comment.