From fc5dc49e72f154d1c0228a7e24afe3956f4ea380 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 2 Jul 2014 09:31:09 -0700 Subject: [PATCH] Avoid constantly calling toLowerCase() --- recentrunes.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/recentrunes.js b/recentrunes.js index 5ca95ed..1703072 100644 --- a/recentrunes.js +++ b/recentrunes.js @@ -731,12 +731,16 @@ rr.SingleLineText = function() { * @return {rr.typeFilter} */ rr.GroupSiblings = function(parentName, childNames) { + parentName = parentName.toUpperCase(); + childNames = childNames.map(function(name) { + return name.toUpperCase(); + }); return function(node) { - if (childNames.indexOf(node.nodeName.toLowerCase()) == -1) { + if (childNames.indexOf(node.nodeName) == -1) { return; } if (node.previousSibling && - node.previousSibling.nodeName.toLowerCase() == parentName) { + node.previousSibling.nodeName == parentName) { // Group with previous node. node.previousSibling.appendChild(node); return; @@ -754,8 +758,9 @@ rr.GroupSiblings = function(parentName, childNames) { * @return {rr.typeFilter} */ rr.RenameElement = function(oldName, newName) { + oldName = oldName.toUpperCase(); return function(node) { - if (node.nodeName.toLowerCase() != oldName) { + if (node.nodeName != oldName) { return; } var newNode = document.createElement(newName); @@ -773,8 +778,9 @@ rr.RenameElement = function(oldName, newName) { * @return {rr.typeFilter} */ rr.SplitElementAndNest = function(originalName, newNames) { + originalName = originalName.toUpperCase(); return function(node) { - if (node.nodeName.toLowerCase() != originalName) { + if (node.nodeName != originalName) { return; } var outerNode, innerNode;