Bug 158315 - Web Inspector: Modernize some function expressions that bind(this) to arrow functions
Summary: Web Inspector: Modernize some function expressions that bind(this) to arrow f...
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: Joseph Pecoraro
URL:
Keywords: DoNotImportToRadar
Depends on:
Blocks:
 
Reported: 2016-06-02 13:44 PDT by Joseph Pecoraro
Modified: 2016-06-02 15:10 PDT (History)
8 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (32.81 KB, patch)
2016-06-02 13:45 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-06-02 13:44:04 PDT
* SUMMARY
Modernize some function expressions that bind(this) to arrow functions

The common pattern:

    setTimeout(function() {
        ...
    }.bind(this), delay);

Can use arrow functions:

    setTimeout(() => {
        ...
    }, delay);

Switching from bind to arrow functions has multiples benefits:

  - it is faster (microbenchmarks)
  - it uses less memory (~252bytes -> 128bytes)
  - the code reads better in most cases

Things to be careful of:

  - if the inner function uses `arguments`, then converting to an arrow function won't work.
Comment 1 Joseph Pecoraro 2016-06-02 13:45:57 PDT
Created attachment 280361 [details]
[PATCH] Proposed Fix
Comment 2 Blaze Burg 2016-06-02 14:05:48 PDT
Comment on attachment 280361 [details]
[PATCH] Proposed Fix

r=me
Comment 3 WebKit Commit Bot 2016-06-02 15:10:34 PDT
Comment on attachment 280361 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 280361

Committed r201620: <http://trac.webkit.org/changeset/201620>
Comment 4 WebKit Commit Bot 2016-06-02 15:10:37 PDT
All reviewed patches have been landed.  Closing bug.