{"action":"closed","issue":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/14022","repository_url":"https://api.github.com/repos/emberjs/ember.js","labels_url":"https://api.github.com/repos/emberjs/ember.js/issues/14022/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/ember.js/issues/14022/comments","events_url":"https://api.github.com/repos/emberjs/ember.js/issues/14022/events","html_url":"https://github.com/emberjs/ember.js/issues/14022","id":169394645,"number":14022,"title":"Why use setAll is the most efficient way to do a setEach?","user":{"login":"carlesnunez","id":5639972,"avatar_url":"https://avatars.githubusercontent.com/u/5639972?v=3","gravatar_id":"","url":"https://api.github.com/users/carlesnunez","html_url":"https://github.com/carlesnunez","followers_url":"https://api.github.com/users/carlesnunez/followers","following_url":"https://api.github.com/users/carlesnunez/following{/other_user}","gists_url":"https://api.github.com/users/carlesnunez/gists{/gist_id}","starred_url":"https://api.github.com/users/carlesnunez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlesnunez/subscriptions","organizations_url":"https://api.github.com/users/carlesnunez/orgs","repos_url":"https://api.github.com/users/carlesnunez/repos","events_url":"https://api.github.com/users/carlesnunez/events{/privacy}","received_events_url":"https://api.github.com/users/carlesnunez/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/emberjs/ember.js/labels/Documentation","name":"Documentation","color":"fbca04"},{"url":"https://api.github.com/repos/emberjs/ember.js/labels/Has%20PR","name":"Has PR","color":"c5def5"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-04T14:54:37Z","updated_at":"2016-08-06T21:54:54Z","closed_at":"2016-08-06T21:54:54Z","body":"Hi, according to ember documentation Ember.enumerable setEach 'is more\r\n    efficient than using other methods defined on this helper':\r\n\r\nIf we drop down to the ember code we can see a function that uses a vanila JS foreach and set method extracted from ember-metal.\r\n\r\n```javascript\r\n/**\r\n    Sets the value on the named property for each member. This is more\r\n    efficient than using other methods defined on this helper. If the object\r\n    implements Ember.Observable, the value will be changed to `set(),` otherwise\r\n    it will be set directly. `null` objects are skipped.\r\n    @method setEach\r\n    @param {String} key The key to set\r\n    @param {Object} value The object to set\r\n    @return {Object} receiver\r\n    @public\r\n  */\r\n  setEach(key, value) {\r\n    return this.forEach(function(item) {\r\n      set(item, key, value);\r\n    });\r\n  },\r\n\r\n```\r\n\r\n\r\nWhy this is the most 'efficient' way to do that? Its because we use set as a method instead of do item.set?\r\n\r\nThank you"}}
{"actor":{"display_login":"rwjblue"}}