Bug 864802 - The _store on each variables view instance is redundant, r=rcampbell

This commit is contained in:
Victor Porof 2013-04-25 09:18:19 +03:00
Родитель 37a09dd732
Коммит 4ddd085b58
2 изменённых файлов: 22 добавлений и 26 удалений

Просмотреть файл

@ -100,7 +100,7 @@ function testHierarchy() {
gScope = gVariablesView._currHierarchy.get("");
gVariable = gVariablesView._currHierarchy.get("[\"\"]");
is(gVariablesView._store.size, 1,
is(gVariablesView._store.length, 1,
"There should be only one scope in the view");
is(gScope._store.size, 1,
"There should be only one variable in the scope");

Просмотреть файл

@ -51,8 +51,7 @@ const STR = Services.strings.createBundle(DBG_STRINGS_URI);
* e.g. { lazyEmpty: true, searchEnabled: true ... }
*/
this.VariablesView = function VariablesView(aParentNode, aFlags = {}) {
this._store = new Map();
this._items = [];
this._store = [];
this._itemsByElement = new WeakMap();
this._prevHierarchy = new Map();
this._currHierarchy = new Map();
@ -103,10 +102,9 @@ VariablesView.prototype = {
this._toggleSearchVisibility(true);
let scope = new Scope(this, aName);
this._store.set(scope.id, scope);
this._items.push(scope);
this._currHierarchy.set(aName, scope);
this._store.push(scope);
this._itemsByElement.set(scope._target, scope);
this._currHierarchy.set(aName, scope);
scope.header = !!aName;
return scope;
},
@ -120,7 +118,7 @@ VariablesView.prototype = {
*/
empty: function VV_empty(aTimeout = this.lazyEmptyDelay) {
// If there are no items in this container, emptying is useless.
if (!this._store.size) {
if (!this._store.length) {
return;
}
// Check if this empty operation may be executed lazily.
@ -136,8 +134,7 @@ VariablesView.prototype = {
list.removeChild(firstChild);
}
this._store.clear();
this._items.length = 0;
this._store.length = 0;
this._itemsByElement.clear();
this._appendEmptyNotice();
@ -163,8 +160,7 @@ VariablesView.prototype = {
let prevList = this._list;
let currList = this._list = this.document.createElement("scrollbox");
this._store.clear();
this._items.length = 0;
this._store.length = 0;
this._itemsByElement.clear();
this._emptyTimeout = this.window.setTimeout(function() {
@ -178,7 +174,7 @@ VariablesView.prototype = {
this._parent.appendChild(currList);
this._boxObject = currList.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
if (!this._store.size) {
if (!this._store.length) {
this._appendEmptyNotice();
this._toggleSearchVisibility(false);
}
@ -305,7 +301,7 @@ VariablesView.prototype = {
set enumVisible(aFlag) {
this._enumVisible = aFlag;
for (let [, scope] of this._store) {
for (let scope of this._store) {
scope._enumVisible = aFlag;
}
},
@ -318,7 +314,7 @@ VariablesView.prototype = {
set nonEnumVisible(aFlag) {
this._nonEnumVisible = aFlag;
for (let [, scope] of this._store) {
for (let scope of this._store) {
scope._nonEnumVisible = aFlag;
}
},
@ -384,7 +380,7 @@ VariablesView.prototype = {
// Hide the variables searchbox container if there are no variables or
// properties to display.
container.hidden = !this._store.size;
container.hidden = !this._store.length;
let searchbox = this._searchboxNode = document.createElement("textbox");
searchbox.className = "variables-view-searchinput devtools-searchinput";
@ -504,7 +500,7 @@ VariablesView.prototype = {
* The variable or property to search for.
*/
_startSearch: function VV__startSearch(aQuery) {
for (let [, scope] of this._store) {
for (let scope of this._store) {
switch (aQuery) {
case "":
scope.expand();
@ -524,7 +520,7 @@ VariablesView.prototype = {
* Expands the first search results in this container.
*/
expandFirstSearchResults: function VV_expandFirstSearchResults() {
for (let [, scope] of this._store) {
for (let scope of this._store) {
let match = scope._firstMatch;
if (match) {
match.expand();
@ -544,7 +540,7 @@ VariablesView.prototype = {
* is found.
*/
_findInVisibleItems: function VV__findInVisibleItems(aPredicate) {
for (let scope of this._items) {
for (let scope of this._store) {
let result = scope._findInVisibleItems(aPredicate);
if (result) {
return result;
@ -566,8 +562,8 @@ VariablesView.prototype = {
* is found.
*/
_findInVisibleItemsReverse: function VV__findInVisibleItemsReverse(aPredicate) {
for (let i = this._items.length - 1; i >= 0; i--) {
let scope = this._items[i];
for (let i = this._store.length - 1; i >= 0; i--) {
let scope = this._store[i];
let result = scope._findInVisibleItemsReverse(aPredicate);
if (result) {
return result;
@ -901,7 +897,6 @@ VariablesView.prototype = {
_window: null,
_store: null,
_items: null,
_prevHierarchy: null,
_currHierarchy: null,
_enumVisible: true,
@ -1131,8 +1126,8 @@ Scope.prototype = {
let variable = new Variable(this, aName, aDescriptor);
this._store.set(aName, variable);
this._variablesView._currHierarchy.set(variable._absoluteName, variable);
this._variablesView._itemsByElement.set(variable._target, variable);
this._variablesView._currHierarchy.set(variable._absoluteName, variable);
variable.header = !!aName;
return variable;
},
@ -1242,7 +1237,8 @@ Scope.prototype = {
// even if they were already displayed before. In this case, show a throbber
// to suggest that this scope is expanding.
if (!this._isExpanding &&
this._variablesView.lazyAppend && this._store.size > LAZY_APPEND_BATCH) {
this._variablesView.lazyAppend &&
this._store.size > LAZY_APPEND_BATCH) {
this._isExpanding = true;
// Start spinning a throbber in this scope's title and allow a few
@ -1933,6 +1929,8 @@ Scope.prototype = {
separatorStr: "",
_store: null,
_enumItems: null,
_nonEnumItems: null,
_fetched: false,
_retrieved: false,
_committed: false,
@ -1953,9 +1951,7 @@ Scope.prototype = {
_name: null,
_title: null,
_enum: null,
_enumItems: null,
_nonenum: null,
_nonEnumItems: null,
_throbber: null
};
@ -2011,8 +2007,8 @@ ViewHelpers.create({ constructor: Variable, proto: Scope.prototype }, {
let property = new Property(this, aName, aDescriptor);
this._store.set(aName, property);
this._variablesView._currHierarchy.set(property._absoluteName, property);
this._variablesView._itemsByElement.set(property._target, property);
this._variablesView._currHierarchy.set(property._absoluteName, property);
property.header = !!aName;
return property;
},