perf($q): move Deferred and Promise methods to prototypes#8437
perf($q): move Deferred and Promise methods to prototypes#8437jeffbcross wants to merge 3 commits intoangular:masterfrom
Conversation
NOTE: Deferred doesn't get all the advantages of moving methods to the prototype, since the constructor binds instance methods to "this" to support unbounded execution. NOTE: This change increases the gzipped version by 100 bytes.
|
Most recent JSPerf tests on my Macbook Air yielded 88949 ops/sec with existing implementation, and 158503 ops/sec with this refactor (78% increase). Note: I recently changed the benchmarks to call jsperf's deferred.resolve directly, without using |
There was a problem hiding this comment.
I prefer the settlePromiseFromHandler method from Bluebird --- we save a few bytes by not re-creating these wrapped callbacks for every then().
This might be good enough for now, but you can see we're creating a lot of duplicate code here and not reusing much.
|
@caitp I added some commits and addressed your comments. Let me know if you think this is good to merge. |
|
I'd still prefer to address https://github.com/angular/angular.js/pull/8437/files#r15715785 --- but worry about that later, it looks good to me. |
|
Landed as 23bc92b |
Opening PR for tests and comparison with other solutions for
$qperf.NOTE: Deferred doesn't get all the advantages of moving methods to the prototype,
since the constructor binds instance methods to "this" to support unbounded execution.
NOTE: This change increases the gzipped version by 100 bytes.