Permalink
Browse files

Linear search for menuitem.id

  • Loading branch information...
1 parent a37f1e7 commit 678777b6f7da7958c85bbc27d5b564fadccb6e82 @xabolcs xabolcs committed Feb 22, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 RestartlessMenuItems.js
View
@@ -228,22 +228,23 @@ var RestartlessMenuItems = {
remove: function _RestartlessMenuItems_remove (options, keepArray) {
if (isThunderbird()) {
- // Find the menuitem by id
+ // Find the menuitem in our list by id
+ let found = false;
let index = -1;
- _menuItems.filter( function isOurMenuItem (element, arrayIndex){
+ found = _menuItems.some( function isOurMenuItem (element, arrayIndex){
if (element.id == options.id)
index = arrayIndex;
return (element.id == options.id);
});
// Un-patch all existing windows
- if (index != -1)
+ if (found)
for each (let w in fixIterator(Services.wm.getEnumerator("mail:3pane")))
unMonkeyPatchWindow(w, _menuItems[index]);
if (!keepArray) {
// Pop out from our list
- if (index != -1)
+ if (found)
_menuItems.splice(index, 1);
// Stop patching future windows if our list is empty

0 comments on commit 678777b

Please sign in to comment.