{"action":"closed","number":332,"pull_request":{"url":"https://api.github.com/repos/rails/sprockets/pulls/332","id":75538963,"html_url":"https://github.com/rails/sprockets/pull/332","diff_url":"https://github.com/rails/sprockets/pull/332.diff","patch_url":"https://github.com/rails/sprockets/pull/332.patch","issue_url":"https://api.github.com/repos/rails/sprockets/issues/332","number":332,"state":"closed","locked":false,"title":"[close #331] Smarter entry lookup","user":{"login":"schneems","id":59744,"avatar_url":"https://avatars.githubusercontent.com/u/59744?v=3","gravatar_id":"","url":"https://api.github.com/users/schneems","html_url":"https://github.com/schneems","followers_url":"https://api.github.com/users/schneems/followers","following_url":"https://api.github.com/users/schneems/following{/other_user}","gists_url":"https://api.github.com/users/schneems/gists{/gist_id}","starred_url":"https://api.github.com/users/schneems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schneems/subscriptions","organizations_url":"https://api.github.com/users/schneems/orgs","repos_url":"https://api.github.com/users/schneems/repos","events_url":"https://api.github.com/users/schneems/events{/privacy}","received_events_url":"https://api.github.com/users/schneems/received_events","type":"User","site_admin":false},"body":"Instead of iterating every entry in a given path, we only pass in valid mime types and explicitly check for basenames that match the extensions we are looking for (when extensions are sufficiently small). \r\n\r\nFor example if we are looking for `foo` with mime of `image/png` instead of looking at EVERY entry in the directory instead we will explicitly look for:\r\n\r\n- foo.png\r\n\r\nThis only works for mime types that have few extensions. It does not scale well for mime types like javascript that would require many many file touches (.coffee, .coffee.erb, .js, .js.erb, .eco, .eco.erb, etc.) even though there may only be a few entries in the directory. When confronted with many extensions (using magic number 3) we go back to the old method of looping through all entries in the directory.\r\n\r\nThis PR makes searching for files with no transforms very fast. For example images in large directories will be much faster as they will only require one lookup instead of looping through all entries.\r\n\r\nUsing the same script from #331\r\n\r\n```\r\n$ be rake sprockets:benchmark\r\nRunning benchmark...\r\n1500 lookups of the same asset took 1.369423\r\n1500 lookups of 1500 different assets took 2.058736\r\n```\r\n\r\nWhich is a substantial speedup.\r\n\r\nIn the future if we could imply the user's preferred extension i.e if a user uses `.coffee.erb` for all JS files and never uses `.eco.js` then we could make this even faster. We could record the file extensions that are used when running in the cache, prefer those when available, when not available fall back to this logic and record the file extension.","created_at":"2016-06-28T19:50:10Z","updated_at":"2016-06-29T01:37:45Z","closed_at":"2016-06-29T01:37:45Z","merged_at":"2016-06-29T01:37:45Z","merge_commit_sha":"f6295e0e0c9c460cfa61679b011c10ae7c975476","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rails/sprockets/pulls/332/commits","review_comments_url":"https://api.github.com/repos/rails/sprockets/pulls/332/comments","review_comment_url":"https://api.github.com/repos/rails/sprockets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/sprockets/issues/332/comments","statuses_url":"https://api.github.com/repos/rails/sprockets/statuses/b6a86f906e0b0ac48438f47966db2bf732ce7af5","head":{"label":"rails:schneems/do-not-loop-through-entries","ref":"schneems/do-not-loop-through-entries","sha":"b6a86f906e0b0ac48438f47966db2bf732ce7af5","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":32104924,"name":"sprockets","full_name":"rails/sprockets","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/sprockets","description":"Rack-based asset packaging system","fork":false,"url":"https://api.github.com/repos/rails/sprockets","forks_url":"https://api.github.com/repos/rails/sprockets/forks","keys_url":"https://api.github.com/repos/rails/sprockets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/sprockets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/sprockets/teams","hooks_url":"https://api.github.com/repos/rails/sprockets/hooks","issue_events_url":"https://api.github.com/repos/rails/sprockets/issues/events{/number}","events_url":"https://api.github.com/repos/rails/sprockets/events","assignees_url":"https://api.github.com/repos/rails/sprockets/assignees{/user}","branches_url":"https://api.github.com/repos/rails/sprockets/branches{/branch}","tags_url":"https://api.github.com/repos/rails/sprockets/tags","blobs_url":"https://api.github.com/repos/rails/sprockets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/sprockets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/sprockets/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/sprockets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/sprockets/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/sprockets/languages","stargazers_url":"https://api.github.com/repos/rails/sprockets/stargazers","contributors_url":"https://api.github.com/repos/rails/sprockets/contributors","subscribers_url":"https://api.github.com/repos/rails/sprockets/subscribers","subscription_url":"https://api.github.com/repos/rails/sprockets/subscription","commits_url":"https://api.github.com/repos/rails/sprockets/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/sprockets/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/sprockets/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/sprockets/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/sprockets/contents/{+path}","compare_url":"https://api.github.com/repos/rails/sprockets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/sprockets/merges","archive_url":"https://api.github.com/repos/rails/sprockets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/sprockets/downloads","issues_url":"https://api.github.com/repos/rails/sprockets/issues{/number}","pulls_url":"https://api.github.com/repos/rails/sprockets/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/sprockets/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/sprockets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/sprockets/labels{/name}","releases_url":"https://api.github.com/repos/rails/sprockets/releases{/id}","deployments_url":"https://api.github.com/repos/rails/sprockets/deployments","created_at":"2015-03-12T21:56:03Z","updated_at":"2016-06-27T04:24:22Z","pushed_at":"2016-06-29T01:37:45Z","git_url":"git://github.com/rails/sprockets.git","ssh_url":"git@github.com:rails/sprockets.git","clone_url":"https://github.com/rails/sprockets.git","svn_url":"https://github.com/rails/sprockets","homepage":"","size":5549,"stargazers_count":267,"watchers_count":267,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":553,"mirror_url":null,"open_issues_count":48,"forks":553,"open_issues":48,"watchers":267,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"0bb48ff938aa26d79c07d5b3b4bca9f19860d83d","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":32104924,"name":"sprockets","full_name":"rails/sprockets","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/sprockets","description":"Rack-based asset packaging system","fork":false,"url":"https://api.github.com/repos/rails/sprockets","forks_url":"https://api.github.com/repos/rails/sprockets/forks","keys_url":"https://api.github.com/repos/rails/sprockets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/sprockets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/sprockets/teams","hooks_url":"https://api.github.com/repos/rails/sprockets/hooks","issue_events_url":"https://api.github.com/repos/rails/sprockets/issues/events{/number}","events_url":"https://api.github.com/repos/rails/sprockets/events","assignees_url":"https://api.github.com/repos/rails/sprockets/assignees{/user}","branches_url":"https://api.github.com/repos/rails/sprockets/branches{/branch}","tags_url":"https://api.github.com/repos/rails/sprockets/tags","blobs_url":"https://api.github.com/repos/rails/sprockets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/sprockets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/sprockets/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/sprockets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/sprockets/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/sprockets/languages","stargazers_url":"https://api.github.com/repos/rails/sprockets/stargazers","contributors_url":"https://api.github.com/repos/rails/sprockets/contributors","subscribers_url":"https://api.github.com/repos/rails/sprockets/subscribers","subscription_url":"https://api.github.com/repos/rails/sprockets/subscription","commits_url":"https://api.github.com/repos/rails/sprockets/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/sprockets/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/sprockets/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/sprockets/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/sprockets/contents/{+path}","compare_url":"https://api.github.com/repos/rails/sprockets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/sprockets/merges","archive_url":"https://api.github.com/repos/rails/sprockets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/sprockets/downloads","issues_url":"https://api.github.com/repos/rails/sprockets/issues{/number}","pulls_url":"https://api.github.com/repos/rails/sprockets/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/sprockets/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/sprockets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/sprockets/labels{/name}","releases_url":"https://api.github.com/repos/rails/sprockets/releases{/id}","deployments_url":"https://api.github.com/repos/rails/sprockets/deployments","created_at":"2015-03-12T21:56:03Z","updated_at":"2016-06-27T04:24:22Z","pushed_at":"2016-06-29T01:37:45Z","git_url":"git://github.com/rails/sprockets.git","ssh_url":"git@github.com:rails/sprockets.git","clone_url":"https://github.com/rails/sprockets.git","svn_url":"https://github.com/rails/sprockets","homepage":"","size":5549,"stargazers_count":267,"watchers_count":267,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":553,"mirror_url":null,"open_issues_count":48,"forks":553,"open_issues":48,"watchers":267,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/sprockets/pulls/332"},"html":{"href":"https://github.com/rails/sprockets/pull/332"},"issue":{"href":"https://api.github.com/repos/rails/sprockets/issues/332"},"comments":{"href":"https://api.github.com/repos/rails/sprockets/issues/332/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/sprockets/pulls/332/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/sprockets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/sprockets/pulls/332/commits"},"statuses":{"href":"https://api.github.com/repos/rails/sprockets/statuses/b6a86f906e0b0ac48438f47966db2bf732ce7af5"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"schneems","id":59744,"avatar_url":"https://avatars.githubusercontent.com/u/59744?v=3","gravatar_id":"","url":"https://api.github.com/users/schneems","html_url":"https://github.com/schneems","followers_url":"https://api.github.com/users/schneems/followers","following_url":"https://api.github.com/users/schneems/following{/other_user}","gists_url":"https://api.github.com/users/schneems/gists{/gist_id}","starred_url":"https://api.github.com/users/schneems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schneems/subscriptions","organizations_url":"https://api.github.com/users/schneems/orgs","repos_url":"https://api.github.com/users/schneems/repos","events_url":"https://api.github.com/users/schneems/events{/privacy}","received_events_url":"https://api.github.com/users/schneems/received_events","type":"User","site_admin":false},"comments":7,"review_comments":3,"commits":2,"additions":38,"deletions":9,"changed_files":4}}
{"actor":{"display_login":"schneems"}}