Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

perf($q): small $q performance optimization #12535

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/promises-aplus/promises-aplus-test-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
var isFunction = function isFunction(value){return typeof value == 'function';};
var isPromiseLike = function isPromiseLike(obj) {return obj && isFunction(obj.then);};
var isObject = function isObject(value){return value != null && typeof value === 'object';};
var isUndefined = function isUndefined(value) {return typeof value === 'undefined';};

var minErr = function minErr (module, constructor) {
return function (){
var ErrorConstructor = constructor || Error;
Expand Down
3 changes: 3 additions & 0 deletions src/ng/q.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ function qFactory(nextTick, exceptionHandler) {

extend(Promise.prototype, {
then: function(onFulfilled, onRejected, progressBack) {
if (isUndefined(onFulfilled) && isUndefined(onRejected) && isUndefined(progressBack)) {
return this;
}
var result = new Deferred();

this.$$state.pending = this.$$state.pending || [];
Expand Down