From dfffbeec4689a62fb8f988ea1b5942c7bf3b3e8e Mon Sep 17 00:00:00 2001 From: kurros Date: Sat, 2 Jan 2016 12:14:48 -0500 Subject: [PATCH] optimize what gets passed to emojione.unicodeToImage --- js/filters.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/filters.js b/js/filters.js index 46fa02e..e51f0a2 100644 --- a/js/filters.js +++ b/js/filters.js @@ -161,7 +161,14 @@ weechat.filter('getBufferQuickKeys', function () { weechat.filter('emojify', function() { return function(text, enable_JS_Emoji) { if (enable_JS_Emoji === true && window.emojione !== undefined) { - return emojione.unicodeToImage(text); + // Emoji live in the D800-DFFF surrogate plane; only bother passing + // this range to CPU-expensive unicodeToImage(); + var emojiRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; + if (emojiRegex.test(text)) { + return emojione.unicodeToImage(text); + } else { + return(text); + } } else { return(text); }