{"action":"created","comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/238421952","pull_request_review_id":180960282,"id":238421952,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODQyMTk1Mg==","diff_hunk":"@@ -66,6 +67,21 @@ const ONE_MINUTE_IN_MS = 60 * 1000;\n  */\n const EMPTY_ARRAY = [];\n \n+/**\n+ * Given a block type object, returns true if an attribute value is sourced\n+ * from a meta property, or false otherwise.\n+ *\n+ * The value is cached weakly by strict object reference to the provided block\n+ * type argument.\n+ *\n+ * @param {WPBlockType} blockType Block type against which to test.\n+ *\n+ * @return {boolean} Whether block type has an meta-sourced attribute.\n+ */\n+const hasMetaSourcedAttribute = createWeakCache( ( blockType ) => {","path":"packages/editor/src/store/selectors.js","position":23,"original_position":23,"commit_id":"3ee21cda760c29db5334da2786f1428a9ddc368b","original_commit_id":"3ee21cda760c29db5334da2786f1428a9ddc368b","user":{"login":"swissspidy","id":841956,"node_id":"MDQ6VXNlcjg0MTk1Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/841956?v=4","gravatar_id":"","url":"https://api.github.com/users/swissspidy","html_url":"https://github.com/swissspidy","followers_url":"https://api.github.com/users/swissspidy/followers","following_url":"https://api.github.com/users/swissspidy/following{/other_user}","gists_url":"https://api.github.com/users/swissspidy/gists{/gist_id}","starred_url":"https://api.github.com/users/swissspidy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swissspidy/subscriptions","organizations_url":"https://api.github.com/users/swissspidy/orgs","repos_url":"https://api.github.com/users/swissspidy/repos","events_url":"https://api.github.com/users/swissspidy/events{/privacy}","received_events_url":"https://api.github.com/users/swissspidy/received_events","type":"User","site_admin":false},"body":"Can‘t we just use memoize instead of rolling our own? We already use it elsewhere, e.g. the i18n package.","created_at":"2018-12-03T20:18:40Z","updated_at":"2018-12-03T20:18:58Z","html_url":"https://github.com/WordPress/gutenberg/pull/12555#discussion_r238421952","pull_request_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments/238421952"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/12555#discussion_r238421952"},"pull_request":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555"}}},"pull_request":{"url":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555","id":235525442,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1NTI1NDQy","html_url":"https://github.com/WordPress/gutenberg/pull/12555","diff_url":"https://github.com/WordPress/gutenberg/pull/12555.diff","patch_url":"https://github.com/WordPress/gutenberg/pull/12555.patch","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/12555","number":12555,"state":"open","locked":false,"title":"Editor: Cache block meta-sourcing for getBlock selector","user":{"login":"aduth","id":1779930,"node_id":"MDQ6VXNlcjE3Nzk5MzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1779930?v=4","gravatar_id":"","url":"https://api.github.com/users/aduth","html_url":"https://github.com/aduth","followers_url":"https://api.github.com/users/aduth/followers","following_url":"https://api.github.com/users/aduth/following{/other_user}","gists_url":"https://api.github.com/users/aduth/gists{/gist_id}","starred_url":"https://api.github.com/users/aduth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduth/subscriptions","organizations_url":"https://api.github.com/users/aduth/orgs","repos_url":"https://api.github.com/users/aduth/repos","events_url":"https://api.github.com/users/aduth/events{/privacy}","received_events_url":"https://api.github.com/users/aduth/received_events","type":"User","site_admin":false},"body":"This pull request seeks to optimize the implementation of `getBlock`, avoiding repeated iterations of a block's attributes to determine whether a meta-sourced attribute exists. Prior to these changes, every call to `getBlock` would iterate each of a block's attributes to determine whether it needed to provide a value from post meta. As there are very few blocks to which this behavior applies, it's largely wasted effort, particularly considering that, since the block type won't change, we especially need not consider block types after it can be determined for the first time that no meta-sourced attributes exist.\r\n\r\n**Implementation notes:**\r\n\r\nThere are many different ways we could go about solving this general issue of attributes derivation for meta attributes. Previously I'd considered some larger refactorings of block attributes sourcing (#5077). This is something which isn't included here, and should still be considered separately (#4989). The changes here are a more direct remedy to the logic of the current implementation.\r\n\r\nEven within such a direct solution, I'm open to suggestions for improvement. I'd considered a few options with code placement of the utilities, and optionally selectors within the `blocks` module to detect whether attributes matching certain predicates exist. It's worth noting that the foundational block has no consideration of meta sources; this is a concept introduced by the editor. Thus, the closest I had got to making this a block concern was by introducing a `getAttributeNamesBySource` selector, which was both needlessly specific and not as impactful (easily-cached) as what's considered here.\r\n\r\nThe advantage of using a WeakMap cache is that it doesn't require manual invalidation, and respects the assumed immutability of a block type once registered. The downside as implemented is that it's another layer of caching, and introduces a few new utility functions which don't fall neatly into existing patterns (`hasMetaSourcedAttribute` is not quite a selector, `createWeakCache` could stand alone as its own module).\r\n\r\n**Testing instructions:**\r\n\r\nThere should be no impact on general use of the editor, namely those behaviors which touch `getBlockAttributes` (keypress in paragraph). Confirm also no regressions on the behavior of blocks whose attributes are sourced from meta.†\r\n\r\n_† No meta-sourced core blocks exist. You may consider [this example Stars block](https://gist.github.com/pento/19b35d621709042fc899e394a9387a54), with revisions to bring it up to date (add `source: 'meta'` to block type definition)_","created_at":"2018-12-03T17:13:59Z","updated_at":"2018-12-03T20:18:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9885045e73cd4fdf721bf2d336a145405d07e848","assignee":null,"assignees":[],"requested_reviewers":[{"login":"mcsf","id":150562,"node_id":"MDQ6VXNlcjE1MDU2Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/150562?v=4","gravatar_id":"","url":"https://api.github.com/users/mcsf","html_url":"https://github.com/mcsf","followers_url":"https://api.github.com/users/mcsf/followers","following_url":"https://api.github.com/users/mcsf/following{/other_user}","gists_url":"https://api.github.com/users/mcsf/gists{/gist_id}","starred_url":"https://api.github.com/users/mcsf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcsf/subscriptions","organizations_url":"https://api.github.com/users/mcsf/orgs","repos_url":"https://api.github.com/users/mcsf/repos","events_url":"https://api.github.com/users/mcsf/events{/privacy}","received_events_url":"https://api.github.com/users/mcsf/received_events","type":"User","site_admin":false},{"login":"youknowriad","id":272444,"node_id":"MDQ6VXNlcjI3MjQ0NA==","avatar_url":"https://avatars3.githubusercontent.com/u/272444?v=4","gravatar_id":"","url":"https://api.github.com/users/youknowriad","html_url":"https://github.com/youknowriad","followers_url":"https://api.github.com/users/youknowriad/followers","following_url":"https://api.github.com/users/youknowriad/following{/other_user}","gists_url":"https://api.github.com/users/youknowriad/gists{/gist_id}","starred_url":"https://api.github.com/users/youknowriad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youknowriad/subscriptions","organizations_url":"https://api.github.com/users/youknowriad/orgs","repos_url":"https://api.github.com/users/youknowriad/repos","events_url":"https://api.github.com/users/youknowriad/events{/privacy}","received_events_url":"https://api.github.com/users/youknowriad/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":731693674,"node_id":"MDU6TGFiZWw3MzE2OTM2NzQ=","url":"https://api.github.com/repos/WordPress/gutenberg/labels/[Type]%20Performance","name":"[Type] Performance","color":"f3f4fe","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555/commits","review_comments_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555/comments","review_comment_url":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/12555/comments","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/3ee21cda760c29db5334da2786f1428a9ddc368b","head":{"label":"WordPress:update/get-block-cache-meta-sourced","ref":"update/get-block-cache-meta-sourced","sha":"3ee21cda760c29db5334da2786f1428a9ddc368b","user":{"login":"WordPress","id":276006,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NjAwNg==","avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"node_id":"MDEwOlJlcG9zaXRvcnk4MDg2MjU4NA==","name":"gutenberg","full_name":"WordPress/gutenberg","private":false,"owner":{"login":"WordPress","id":276006,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NjAwNg==","avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-12-03T19:34:16Z","pushed_at":"2018-12-03T18:46:38Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/","size":35237,"stargazers_count":3820,"watchers_count":3820,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1081,"mirror_url":null,"archived":false,"open_issues_count":1608,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1081,"open_issues":1608,"watchers":3820,"default_branch":"master"}},"base":{"label":"WordPress:master","ref":"master","sha":"652a662a8aba2b621978871e56706990d5deb653","user":{"login":"WordPress","id":276006,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NjAwNg==","avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"repo":{"id":80862584,"node_id":"MDEwOlJlcG9zaXRvcnk4MDg2MjU4NA==","name":"gutenberg","full_name":"WordPress/gutenberg","private":false,"owner":{"login":"WordPress","id":276006,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NjAwNg==","avatar_url":"https://avatars0.githubusercontent.com/u/276006?v=4","gravatar_id":"","url":"https://api.github.com/users/WordPress","html_url":"https://github.com/WordPress","followers_url":"https://api.github.com/users/WordPress/followers","following_url":"https://api.github.com/users/WordPress/following{/other_user}","gists_url":"https://api.github.com/users/WordPress/gists{/gist_id}","starred_url":"https://api.github.com/users/WordPress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WordPress/subscriptions","organizations_url":"https://api.github.com/users/WordPress/orgs","repos_url":"https://api.github.com/users/WordPress/repos","events_url":"https://api.github.com/users/WordPress/events{/privacy}","received_events_url":"https://api.github.com/users/WordPress/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/WordPress/gutenberg","description":"Printing since 1440. Development hub for the editor focus in core. Plugin is available from the official WordPress repository.","fork":false,"url":"https://api.github.com/repos/WordPress/gutenberg","forks_url":"https://api.github.com/repos/WordPress/gutenberg/forks","keys_url":"https://api.github.com/repos/WordPress/gutenberg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WordPress/gutenberg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WordPress/gutenberg/teams","hooks_url":"https://api.github.com/repos/WordPress/gutenberg/hooks","issue_events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/events{/number}","events_url":"https://api.github.com/repos/WordPress/gutenberg/events","assignees_url":"https://api.github.com/repos/WordPress/gutenberg/assignees{/user}","branches_url":"https://api.github.com/repos/WordPress/gutenberg/branches{/branch}","tags_url":"https://api.github.com/repos/WordPress/gutenberg/tags","blobs_url":"https://api.github.com/repos/WordPress/gutenberg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WordPress/gutenberg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WordPress/gutenberg/git/refs{/sha}","trees_url":"https://api.github.com/repos/WordPress/gutenberg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WordPress/gutenberg/statuses/{sha}","languages_url":"https://api.github.com/repos/WordPress/gutenberg/languages","stargazers_url":"https://api.github.com/repos/WordPress/gutenberg/stargazers","contributors_url":"https://api.github.com/repos/WordPress/gutenberg/contributors","subscribers_url":"https://api.github.com/repos/WordPress/gutenberg/subscribers","subscription_url":"https://api.github.com/repos/WordPress/gutenberg/subscription","commits_url":"https://api.github.com/repos/WordPress/gutenberg/commits{/sha}","git_commits_url":"https://api.github.com/repos/WordPress/gutenberg/git/commits{/sha}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/comments{/number}","issue_comment_url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments{/number}","contents_url":"https://api.github.com/repos/WordPress/gutenberg/contents/{+path}","compare_url":"https://api.github.com/repos/WordPress/gutenberg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WordPress/gutenberg/merges","archive_url":"https://api.github.com/repos/WordPress/gutenberg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WordPress/gutenberg/downloads","issues_url":"https://api.github.com/repos/WordPress/gutenberg/issues{/number}","pulls_url":"https://api.github.com/repos/WordPress/gutenberg/pulls{/number}","milestones_url":"https://api.github.com/repos/WordPress/gutenberg/milestones{/number}","notifications_url":"https://api.github.com/repos/WordPress/gutenberg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WordPress/gutenberg/labels{/name}","releases_url":"https://api.github.com/repos/WordPress/gutenberg/releases{/id}","deployments_url":"https://api.github.com/repos/WordPress/gutenberg/deployments","created_at":"2017-02-03T19:34:19Z","updated_at":"2018-12-03T19:34:16Z","pushed_at":"2018-12-03T18:46:38Z","git_url":"git://github.com/WordPress/gutenberg.git","ssh_url":"git@github.com:WordPress/gutenberg.git","clone_url":"https://github.com/WordPress/gutenberg.git","svn_url":"https://github.com/WordPress/gutenberg","homepage":"https://wordpress.org/plugins/gutenberg/","size":35237,"stargazers_count":3820,"watchers_count":3820,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1081,"mirror_url":null,"archived":false,"open_issues_count":1608,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1081,"open_issues":1608,"watchers":3820,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555"},"html":{"href":"https://github.com/WordPress/gutenberg/pull/12555"},"issue":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/12555"},"comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/issues/12555/comments"},"review_comments":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555/comments"},"review_comment":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WordPress/gutenberg/pulls/12555/commits"},"statuses":{"href":"https://api.github.com/repos/WordPress/gutenberg/statuses/3ee21cda760c29db5334da2786f1428a9ddc368b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"swissspidy"}}