Changeset 139862 in webkit


Ignore:
Timestamp:
Jan 16, 2013 2:43:52 AM (11 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Store project UISourceCodes in a map with uri as a key for faster lookup.
https://bugs.webkit.org/show_bug.cgi?id=106911

Reviewed by Pavel Feldman.

  • inspector/front-end/Workspace.js:

(WebInspector.Project):
(WebInspector.Project.prototype._fileAdded):
(WebInspector.Project.prototype._fileRemoved):
(WebInspector.Project.prototype._reset):
(WebInspector.Project.prototype.uiSourceCodeForOriginURL):
(WebInspector.Project.prototype.uiSourceCodeForURI):
(WebInspector.Project.prototype.uiSourceCodes):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139860 r139862  
     12013-01-15  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Store project UISourceCodes in a map with uri as a key for faster lookup.
     4        https://bugs.webkit.org/show_bug.cgi?id=106911
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/front-end/Workspace.js:
     9        (WebInspector.Project):
     10        (WebInspector.Project.prototype._fileAdded):
     11        (WebInspector.Project.prototype._fileRemoved):
     12        (WebInspector.Project.prototype._reset):
     13        (WebInspector.Project.prototype.uiSourceCodeForOriginURL):
     14        (WebInspector.Project.prototype.uiSourceCodeForURI):
     15        (WebInspector.Project.prototype.uiSourceCodes):
     16
    1172013-01-15  Vsevolod Vlasov  <vsevik@chromium.org>
    218
  • trunk/Source/WebCore/inspector/front-end/Workspace.js

    r139860 r139862  
    132132{
    133133    this._name = name;
    134     this._uiSourceCodes = [];
     134    /** @type {Object.<string, WebInspector.UISourceCode>} */
     135    this._uiSourceCodesForURI = {};
    135136    this._workspace = workspace;
    136137    this._workspaceProvider = workspaceProvider;
     
    168169        uiSourceCode.isContentScript = fileDescriptor.isContentScript;
    169170        uiSourceCode.isSnippet = fileDescriptor.isSnippet;
    170         this._uiSourceCodes.push(uiSourceCode);
     171        this._uiSourceCodesForURI[uiSourceCode.uri()] = uiSourceCode;
    171172        this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
    172173    },
     
    178179        if (!uiSourceCode)
    179180            return;
    180         this._uiSourceCodes.splice(this._uiSourceCodes.indexOf(uiSourceCode), 1);
     181        delete this._uiSourceCodesForURI[uiSourceCode.uri()];
    181182        this._workspace.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, uiSourceCode);
    182183    },
     
    185186    {
    186187        this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectWillReset, this);
    187         this._uiSourceCodes = [];
     188        this._uiSourceCodesForURI = {};
    188189    },
    189190
     
    194195    uiSourceCodeForOriginURL: function(originURL)
    195196    {
    196         for (var i = 0; i < this._uiSourceCodes.length; ++i) {
    197             if (this._uiSourceCodes[i].originURL() === originURL)
    198                 return this._uiSourceCodes[i];
     197        for (var uri in this._uiSourceCodesForURI) {
     198            var uiSourceCode = this._uiSourceCodesForURI[uri];
     199            if (uiSourceCode.originURL() === originURL)
     200                return uiSourceCode;
    199201        }
    200202        return null;
     
    207209    uiSourceCodeForURI: function(uri)
    208210    {
    209         for (var i = 0; i < this._uiSourceCodes.length; ++i) {
    210             if (this._uiSourceCodes[i].uri() === uri)
    211                 return this._uiSourceCodes[i];
    212         }
    213         return null;
     211        return this._uiSourceCodesForURI[uri];
    214212    },
    215213
     
    219217    uiSourceCodes: function()
    220218    {
    221         return this._uiSourceCodes;
     219        return Object.values(this._uiSourceCodesForURI);
    222220    },
    223221
Note: See TracChangeset for help on using the changeset viewer.