Bug 168549 - Web Inspector: Use Maps in FrameResourceManager instead of objects
Summary: Web Inspector: Use Maps in FrameResourceManager instead of objects
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-17 20:22 PST by Nikita Vasilyev
Modified: 2017-02-17 22:59 PST (History)
3 users (show)

See Also:


Attachments
Patch (12.04 KB, patch)
2017-02-17 20:42 PST, Nikita Vasilyev
joepeck: review+
joepeck: commit-queue-
Details | Formatted Diff | Diff
Patch (12.00 KB, patch)
2017-02-17 22:22 PST, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2017-02-17 20:22:25 PST
Also, instead of using `delete` operator use Map#delete.
Comment 1 Radar WebKit Bug Importer 2017-02-17 20:22:45 PST
<rdar://problem/30590110>
Comment 2 Nikita Vasilyev 2017-02-17 20:42:06 PST
Created attachment 302042 [details]
Patch
Comment 3 Joseph Pecoraro 2017-02-17 20:49:33 PST
Comment on attachment 302042 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=302042&action=review

r=me

> Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js:72
>          var frames = [];
> -        for (var key in this._frameIdentifierMap)
> -            frames.push(this._frameIdentifierMap[key]);
> +        for (let [key, value] of this._frameIdentifierMap)
> +            frames.push(value);
>  
>          return frames;

How about just [...map.values()]

> Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js:536
> +        this._resourceRequestIdentifierMap = new Map;
> +        this._frameIdentifierMap = new Map;

These could be .clear(), but I think new Map is fine.
Comment 4 Nikita Vasilyev 2017-02-17 22:19:16 PST
(In reply to comment #3)
> Comment on attachment 302042 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=302042&action=review
> 
> r=me
> 
> > Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js:72
> >          var frames = [];
> > -        for (var key in this._frameIdentifierMap)
> > -            frames.push(this._frameIdentifierMap[key]);
> > +        for (let [key, value] of this._frameIdentifierMap)
> > +            frames.push(value);
> >  
> >          return frames;
> 
> How about just [...map.values()]

This's so much more concise! I forgot that `...` can be used with any iterator.
Comment 5 Nikita Vasilyev 2017-02-17 22:22:11 PST
Created attachment 302046 [details]
Patch
Comment 6 WebKit Commit Bot 2017-02-17 22:59:24 PST
Comment on attachment 302046 [details]
Patch

Clearing flags on attachment: 302046

Committed r212603: <http://trac.webkit.org/changeset/212603>
Comment 7 WebKit Commit Bot 2017-02-17 22:59:27 PST
All reviewed patches have been landed.  Closing bug.