{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/13293","labels_url":"https://api.github.com/repos/angular/angular.js/issues/13293/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13293/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/13293/events","html_url":"https://github.com/angular/angular.js/pull/13293","id":116286954,"number":13293,"title":"perf($q): reduce closures","user":{"login":"jbedard","id":89246,"avatar_url":"https://avatars.githubusercontent.com/u/89246?v=3","gravatar_id":"","url":"https://api.github.com/users/jbedard","html_url":"https://github.com/jbedard","followers_url":"https://api.github.com/users/jbedard/followers","following_url":"https://api.github.com/users/jbedard/following{/other_user}","gists_url":"https://api.github.com/users/jbedard/gists{/gist_id}","starred_url":"https://api.github.com/users/jbedard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbedard/subscriptions","organizations_url":"https://api.github.com/users/jbedard/orgs","repos_url":"https://api.github.com/users/jbedard/repos","events_url":"https://api.github.com/users/jbedard/events{/privacy}","received_events_url":"https://api.github.com/users/jbedard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular.js/labels/cla:%20yes","name":"cla: yes","color":"bfe5bf"},{"url":"https://api.github.com/repos/angular/angular.js/labels/type:%20perf","name":"type: perf","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-11-11T08:14:34Z","updated_at":"2015-11-16T01:46:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/angular/angular.js/pulls/13293","html_url":"https://github.com/angular/angular.js/pull/13293","diff_url":"https://github.com/angular/angular.js/pull/13293.diff","patch_url":"https://github.com/angular/angular.js/pull/13293.patch"},"body":"First commit:\r\n* Only wrap the internal `$$reject` / `$$resolve` when necessary, which is when a promise is resolved with another promise as the result. This is now in a `$$delayResolve` method.\r\n* Move the \"call once\" logic into the `$$reject` / `$$resolve` methods, it already existed in `notify`\r\n* ~~Use `isPromiseLike` instead of redefining it, this is a slight functional change since they were different~~\r\n\r\nSecond:\r\n* Only bind the `Deferred` methods when the `Deferred` will be returned publicly (`$q.defer`). Most of the time it is only used internally and the binding isn't necessary.  The other option is to stop binding them completely which would be nicer but would be a breaking change.\r\n\r\nAll the `Deferred` / `Promise` methods use somewhere between 20-80% less memory except for a few with no changes (`$q.defer()`, `promise.then()` (no args))..."},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/156887959","html_url":"https://github.com/angular/angular.js/pull/13293#issuecomment-156887959","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13293","id":156887959,"user":{"login":"jbedard","id":89246,"avatar_url":"https://avatars.githubusercontent.com/u/89246?v=3","gravatar_id":"","url":"https://api.github.com/users/jbedard","html_url":"https://github.com/jbedard","followers_url":"https://api.github.com/users/jbedard/followers","following_url":"https://api.github.com/users/jbedard/following{/other_user}","gists_url":"https://api.github.com/users/jbedard/gists{/gist_id}","starred_url":"https://api.github.com/users/jbedard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbedard/subscriptions","organizations_url":"https://api.github.com/users/jbedard/orgs","repos_url":"https://api.github.com/users/jbedard/repos","events_url":"https://api.github.com/users/jbedard/events{/privacy}","received_events_url":"https://api.github.com/users/jbedard/received_events","type":"User","site_admin":false},"created_at":"2015-11-16T01:46:55Z","updated_at":"2015-11-16T01:46:55Z","body":"Do you think it's worth removing these closures at all? I can think of many other ways of doing it...  For example your snippet but with the resolve/notify inlined removes 2/3 closures (but the reject can not be inlined because it is also used in the `catch` block).\r\n\r\nI've swapped the order of the commits in this PR so the `simpleBind` one is first and doesn't depend on the other..."}}