Microoptimization

Move word length check before banned emotes check
This commit is contained in:
Jiiks 2015-12-11 08:46:37 +02:00
parent 6e621098e3
commit 97daae9090
1 changed files with 4 additions and 4 deletions

View File

@ -367,7 +367,7 @@ EmoteModule.prototype.getNodes = function(node) {
var bemotes = [];
var spoilered = [];
//TODO Functional titles
//TODO Edited emotes
EmoteModule.prototype.injectEmote = function(node) {
if(typeof emotesTwitch === 'undefined') return;
@ -406,13 +406,13 @@ EmoteModule.prototype.injectEmote = function(node) {
return;
}
if($.inArray(word, bemotes) != -1) return;
if(word.length < 4) {
return;
}
if($.inArray(word, bemotes) != -1) return;
if (emotesTwitch.emotes.hasOwnProperty(word)) {
var len = Math.round(word.length / 4);
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + twitchEmoteUrlStart + emotesTwitch.emotes[word].image_id + twitchEmoteUrlEnd + '" />' );