From 3b1681f497737a4b7c61089480e2c802126d1768 Mon Sep 17 00:00:00 2001 From: Mike Chambers Date: Fri, 27 Apr 2012 15:45:53 -0700 Subject: [PATCH 1/2] Removing link to Google Plus Page. Will re-add once we drive broader awareness. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1ef83fd8136..32d0ec8470e 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,6 @@ Not sure you needed the exclamation point there, but I like your enthusiasm. * **IRC:** [#brackets on freenode](http://freenode.net) * **Mailing list (users):** http://groups.google.com/group/codebrackets * **Mailing list (developers):** http://groups.google.com/group/brackets-dev -* **Google+:** [Brackets](https://plus.google.com/b/115365194873502050036/) From 68dba5fdf50c23197ce57b3329813493c759aae2 Mon Sep 17 00:00:00 2001 From: Mike Chambers Date: Mon, 7 May 2012 20:02:07 -0700 Subject: [PATCH 2/2] Refactoring of _normalizeKeyDescriptorString. Moved _isModifier definition out of _normalizeKeyDescriptorString and into scope of KeyMap require.js module. Prior, _isModifier was defined each time _normalizeKeyDescriptorString wall called (18 time at startup). This lead to unnecessary code execution as well as garbage collection. Added an additional argument to _isModifier, origDescriptor, which is used in a debug statement within the function. _isModifier is now scoped to the KeyMap module, and thus will be in memory as long as the module is in memory. --- src/command/KeyMap.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/command/KeyMap.js b/src/command/KeyMap.js index e8b8fc2726a..fb6a86133ba 100644 --- a/src/command/KeyMap.js +++ b/src/command/KeyMap.js @@ -66,6 +66,19 @@ define(function (require, exports, module) { return keyDescriptor.join("-"); } + function _isModifier(left, right, previouslyFound, origDescriptor) { + if (!left || !right) { + return false; + } + left = left.trim().toLowerCase(); + right = right.trim().toLowerCase(); + var matched = (left.length > 0 && left === right); + if (matched && previouslyFound) { + console.log("KeyMap _normalizeKeyDescriptorString() - Modifier defined twice: " + origDescriptor); + } + return matched; + } + /** * @private * normalizes the incoming key descriptor so the modifier keys are always specified in the correct order @@ -78,31 +91,18 @@ define(function (require, exports, module) { hasShift = false, key = ""; - function _isModifier(left, right, previouslyFound) { - if (!left || !right) { - return false; - } - left = left.trim().toLowerCase(); - right = right.trim().toLowerCase(); - var matched = (left.length > 0 && left === right); - if (matched && previouslyFound) { - console.log("KeyMap _normalizeKeyDescriptorString() - Modifier defined twice: " + origDescriptor); - } - return matched; - } - origDescriptor.split("-").forEach(function parseDescriptor(ele, i, arr) { if (_isModifier("ctrl", ele, hasCtrl)) { hasCtrl = true; - } else if (_isModifier("cmd", ele, hasCtrl)) { + } else if (_isModifier("cmd", ele, hasCtrl, origDescriptor)) { console.log("KeyMap _normalizeKeyDescriptorString() - Cmd getting mapped to Ctrl from: " + origDescriptor); hasCtrl = true; - } else if (_isModifier("alt", ele, hasAlt)) { + } else if (_isModifier("alt", ele, hasAlt, origDescriptor)) { hasAlt = true; - } else if (_isModifier("opt", ele, hasAlt)) { + } else if (_isModifier("opt", ele, hasAlt, origDescriptor)) { console.log("KeyMap _normalizeKeyDescriptorString() - Opt getting mapped to Alt from: " + origDescriptor); hasAlt = true; - } else if (_isModifier("shift", ele, hasShift)) { + } else if (_isModifier("shift", ele, hasShift, origDescriptor)) { hasShift = true; } else if (key.length > 0) { console.log("KeyMap _normalizeKeyDescriptorString() - Multiple keys defined. Using key: " + key + " from: " + origDescriptor);