{"action":"created","comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/comments/83501273","pull_request_review_id":4344152,"id":83501273,"diff_hunk":"@@ -253,23 +253,40 @@ void OfflineDownload::ensureResource(const Resource& resource,\n     *workRequestsIt = util::RunLoop::Get()->invokeCancellable([=]() {\n         requests.erase(workRequestsIt);\n \n-        optional<std::pair<Response, uint64_t>> offlineResponse =\n-            offlineDatabase.getRegionResource(id, resource);\n-        if (offlineResponse) {\n-            if (callback) {\n-                callback(offlineResponse->first);\n-            }\n+        if (callback) {","path":"platform/default/mbgl/storage/offline_download.cpp","position":10,"original_position":10,"commit_id":"61da0755397f6ca82b009ee576ad00f5e991b257","original_commit_id":"61da0755397f6ca82b009ee576ad00f5e991b257","user":{"login":"jfirebaugh","id":98601,"avatar_url":"https://avatars.githubusercontent.com/u/98601?v=3","gravatar_id":"","url":"https://api.github.com/users/jfirebaugh","html_url":"https://github.com/jfirebaugh","followers_url":"https://api.github.com/users/jfirebaugh/followers","following_url":"https://api.github.com/users/jfirebaugh/following{/other_user}","gists_url":"https://api.github.com/users/jfirebaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/jfirebaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfirebaugh/subscriptions","organizations_url":"https://api.github.com/users/jfirebaugh/orgs","repos_url":"https://api.github.com/users/jfirebaugh/repos","events_url":"https://api.github.com/users/jfirebaugh/events{/privacy}","received_events_url":"https://api.github.com/users/jfirebaugh/received_events","type":"User","site_admin":false},"body":"Can you refactor this change so that the common code in each branch of this conditional is not repeated? E.g.:\r\n\r\n```c++\r\nauto getResourceSizeInDatabase = [&] () -> optional<uint64_t> {\r\n    if (!callback) {\r\n        return offlineDatabase.hasRegionResource(id, resource);\r\n    }\r\n    optional<std::pair<Response, uint64_t>> response =\r\n        offlineDatabase.getRegionResource(id, resource);\r\n    if (!response) {\r\n        return {};\r\n    }\r\n    callback(response->first);\r\n    return response->second;\r\n}\r\n\r\noptional<uint64_t> offlineResponse = getResourceSizeInDatabase();\r\nif (offlineResponse) {\r\n    ...\r\n}\r\n```","created_at":"2016-10-14T21:05:11Z","updated_at":"2016-10-14T21:15:42Z","html_url":"https://github.com/mapbox/mapbox-gl-native/pull/6707#discussion_r83501273","pull_request_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707","_links":{"self":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/comments/83501273"},"html":{"href":"https://github.com/mapbox/mapbox-gl-native/pull/6707#discussion_r83501273"},"pull_request":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707"}}},"pull_request":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707","id":89453511,"html_url":"https://github.com/mapbox/mapbox-gl-native/pull/6707","diff_url":"https://github.com/mapbox/mapbox-gl-native/pull/6707.diff","patch_url":"https://github.com/mapbox/mapbox-gl-native/pull/6707.patch","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6707","number":6707,"state":"open","locked":false,"title":"added hasRegionResource when the content are not needed by the caller","user":{"login":"halset","id":445229,"avatar_url":"https://avatars.githubusercontent.com/u/445229?v=3","gravatar_id":"","url":"https://api.github.com/users/halset","html_url":"https://github.com/halset","followers_url":"https://api.github.com/users/halset/followers","following_url":"https://api.github.com/users/halset/following{/other_user}","gists_url":"https://api.github.com/users/halset/gists{/gist_id}","starred_url":"https://api.github.com/users/halset/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halset/subscriptions","organizations_url":"https://api.github.com/users/halset/orgs","repos_url":"https://api.github.com/users/halset/repos","events_url":"https://api.github.com/users/halset/events{/privacy}","received_events_url":"https://api.github.com/users/halset/received_events","type":"User","site_admin":false},"body":"When a offline download continues with lots of existing tiles, it is too expensive to get the tile and even decompress it to only check if it exist. This add hasRegionResource, hasResource and hasTile to the existing get-methods. This solve one part of #6651 and is a subset of the earlier #6691.","created_at":"2016-10-14T20:57:15Z","updated_at":"2016-10-14T21:21:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b0f0da481bdb313eb7332fa0ac5dee4db88d66f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707/commits","review_comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707/comments","review_comment_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6707/comments","statuses_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/statuses/61da0755397f6ca82b009ee576ad00f5e991b257","head":{"label":"halset:offline-performance-hasResource","ref":"offline-performance-hasResource","sha":"61da0755397f6ca82b009ee576ad00f5e991b257","user":{"login":"halset","id":445229,"avatar_url":"https://avatars.githubusercontent.com/u/445229?v=3","gravatar_id":"","url":"https://api.github.com/users/halset","html_url":"https://github.com/halset","followers_url":"https://api.github.com/users/halset/followers","following_url":"https://api.github.com/users/halset/following{/other_user}","gists_url":"https://api.github.com/users/halset/gists{/gist_id}","starred_url":"https://api.github.com/users/halset/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halset/subscriptions","organizations_url":"https://api.github.com/users/halset/orgs","repos_url":"https://api.github.com/users/halset/repos","events_url":"https://api.github.com/users/halset/events{/privacy}","received_events_url":"https://api.github.com/users/halset/received_events","type":"User","site_admin":false},"repo":{"id":42304023,"name":"mapbox-gl-native","full_name":"halset/mapbox-gl-native","owner":{"login":"halset","id":445229,"avatar_url":"https://avatars.githubusercontent.com/u/445229?v=3","gravatar_id":"","url":"https://api.github.com/users/halset","html_url":"https://github.com/halset","followers_url":"https://api.github.com/users/halset/followers","following_url":"https://api.github.com/users/halset/following{/other_user}","gists_url":"https://api.github.com/users/halset/gists{/gist_id}","starred_url":"https://api.github.com/users/halset/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halset/subscriptions","organizations_url":"https://api.github.com/users/halset/orgs","repos_url":"https://api.github.com/users/halset/repos","events_url":"https://api.github.com/users/halset/events{/privacy}","received_events_url":"https://api.github.com/users/halset/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/halset/mapbox-gl-native","description":"Render Mapbox styles in mobile, desktop, and node applications using C++ and OpenGL","fork":true,"url":"https://api.github.com/repos/halset/mapbox-gl-native","forks_url":"https://api.github.com/repos/halset/mapbox-gl-native/forks","keys_url":"https://api.github.com/repos/halset/mapbox-gl-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halset/mapbox-gl-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halset/mapbox-gl-native/teams","hooks_url":"https://api.github.com/repos/halset/mapbox-gl-native/hooks","issue_events_url":"https://api.github.com/repos/halset/mapbox-gl-native/issues/events{/number}","events_url":"https://api.github.com/repos/halset/mapbox-gl-native/events","assignees_url":"https://api.github.com/repos/halset/mapbox-gl-native/assignees{/user}","branches_url":"https://api.github.com/repos/halset/mapbox-gl-native/branches{/branch}","tags_url":"https://api.github.com/repos/halset/mapbox-gl-native/tags","blobs_url":"https://api.github.com/repos/halset/mapbox-gl-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halset/mapbox-gl-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halset/mapbox-gl-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/halset/mapbox-gl-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halset/mapbox-gl-native/statuses/{sha}","languages_url":"https://api.github.com/repos/halset/mapbox-gl-native/languages","stargazers_url":"https://api.github.com/repos/halset/mapbox-gl-native/stargazers","contributors_url":"https://api.github.com/repos/halset/mapbox-gl-native/contributors","subscribers_url":"https://api.github.com/repos/halset/mapbox-gl-native/subscribers","subscription_url":"https://api.github.com/repos/halset/mapbox-gl-native/subscription","commits_url":"https://api.github.com/repos/halset/mapbox-gl-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/halset/mapbox-gl-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/halset/mapbox-gl-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/halset/mapbox-gl-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/halset/mapbox-gl-native/contents/{+path}","compare_url":"https://api.github.com/repos/halset/mapbox-gl-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halset/mapbox-gl-native/merges","archive_url":"https://api.github.com/repos/halset/mapbox-gl-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halset/mapbox-gl-native/downloads","issues_url":"https://api.github.com/repos/halset/mapbox-gl-native/issues{/number}","pulls_url":"https://api.github.com/repos/halset/mapbox-gl-native/pulls{/number}","milestones_url":"https://api.github.com/repos/halset/mapbox-gl-native/milestones{/number}","notifications_url":"https://api.github.com/repos/halset/mapbox-gl-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halset/mapbox-gl-native/labels{/name}","releases_url":"https://api.github.com/repos/halset/mapbox-gl-native/releases{/id}","deployments_url":"https://api.github.com/repos/halset/mapbox-gl-native/deployments","created_at":"2015-09-11T11:10:43Z","updated_at":"2016-04-20T10:27:57Z","pushed_at":"2016-10-14T20:54:32Z","git_url":"git://github.com/halset/mapbox-gl-native.git","ssh_url":"git@github.com:halset/mapbox-gl-native.git","clone_url":"https://github.com/halset/mapbox-gl-native.git","svn_url":"https://github.com/halset/mapbox-gl-native","homepage":"https://mapbox.com/mobile","size":54961,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mapbox:master","ref":"master","sha":"242c7f8fe62eb863cf300855aee2f04022311288","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":16286131,"name":"mapbox-gl-native","full_name":"mapbox/mapbox-gl-native","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/mapbox-gl-native","description":"Render Mapbox styles in mobile, desktop, and node applications using C++ and OpenGL","fork":false,"url":"https://api.github.com/repos/mapbox/mapbox-gl-native","forks_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/forks","keys_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/teams","hooks_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/hooks","issue_events_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/events","assignees_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/tags","blobs_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/languages","stargazers_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/stargazers","contributors_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/contributors","subscribers_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/subscribers","subscription_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/subscription","commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/merges","archive_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/downloads","issues_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/deployments","created_at":"2014-01-27T17:14:48Z","updated_at":"2016-10-14T13:09:17Z","pushed_at":"2016-10-14T21:10:24Z","git_url":"git://github.com/mapbox/mapbox-gl-native.git","ssh_url":"git@github.com:mapbox/mapbox-gl-native.git","clone_url":"https://github.com/mapbox/mapbox-gl-native.git","svn_url":"https://github.com/mapbox/mapbox-gl-native","homepage":"https://mapbox.com/mobile","size":133097,"stargazers_count":1502,"watchers_count":1502,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":442,"mirror_url":null,"open_issues_count":638,"forks":442,"open_issues":638,"watchers":1502,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707"},"html":{"href":"https://github.com/mapbox/mapbox-gl-native/pull/6707"},"issue":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6707"},"comments":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/6707/comments"},"review_comments":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707/comments"},"review_comment":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/pulls/6707/commits"},"statuses":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-native/statuses/61da0755397f6ca82b009ee576ad00f5e991b257"}}}}
{"actor":{"display_login":"jfirebaugh"}}