From 643ca7302f0d4af75e4a06f292b206e82fe6edbc Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Wed, 22 May 2013 10:10:28 +0100 Subject: [PATCH] Inline the anyOpen() function to avoid overhead of function call --- client/assets/dev/utils.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/client/assets/dev/utils.js b/client/assets/dev/utils.js index f35803f..bf10e67 100644 --- a/client/assets/dev/utils.js +++ b/client/assets/dev/utils.js @@ -269,13 +269,10 @@ function formatIRCMsg (msg) { underline: false, colour: false }, - anyOpen = function () { - return (openTags.bold || openTags.italic || openTags.underline || openTags.colour); - }, spanFromOpen = function () { var style = '', colours; - if (!anyOpen()) { + if (!(openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { return ''; } else { style += (openTags.bold) ? 'font-weight: bold; ' : ''; @@ -337,28 +334,28 @@ function formatIRCMsg (msg) { for (i = 0; i < msg.length; i++) { switch (msg[i]) { case '\x02': - if (anyOpen()) { + if ((openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { out += currentTag + ''; } openTags.bold = !openTags.bold; currentTag = spanFromOpen(); break; case '\x1D': - if (anyOpen()) { + if (an(openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { out += currentTag + ''; } openTags.italic = !openTags.italic; currentTag = spanFromOpen(); break; case '\x1F': - if (anyOpen()) { + if ((openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { out += currentTag + ''; } openTags.underline = !openTags.underline; currentTag = spanFromOpen(); break; case '\x03': - if (anyOpen()) { + if ((openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { out += currentTag + ''; } match = colourMatch(msg.substr(i, 6)); @@ -376,13 +373,13 @@ function formatIRCMsg (msg) { currentTag = spanFromOpen(); break; case '\x0F': - if (anyOpen()) { + if ((openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { out += currentTag + ''; } openTags.bold = openTags.italic = openTags.underline = openTags.colour = false; break; default: - if (anyOpen()) { + if ((openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { currentTag += msg[i]; } else { out += msg[i]; @@ -390,7 +387,7 @@ function formatIRCMsg (msg) { break; } } - if (anyOpen()) { + if ((openTags.bold || openTags.italic || openTags.underline || openTags.colour)) { out += currentTag + ''; } return out; -- 2.25.1