{"action":"created","comment":{"url":"https://api.github.com/repos/sindresorhus/pure/pulls/comments/35477443","id":35477443,"diff_hunk":"@@ -57,17 +59,28 @@ prompt_pure_clear_screen() {\n }\n \n prompt_pure_check_git_arrows() {\n+\t# reset git arrows\n+\tprompt_pure_git_arrows=","path":"pure.zsh","position":46,"original_position":46,"commit_id":"b35b18a08a638d41ee11168b6d6a0231f76ca55a","original_commit_id":"b35b18a08a638d41ee11168b6d6a0231f76ca55a","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"body":"Can we have this function return a value instead of setting a global variable?","created_at":"2015-07-25T00:57:22Z","updated_at":"2015-07-25T00:57:22Z","html_url":"https://github.com/sindresorhus/pure/pull/149#discussion_r35477443","pull_request_url":"https://api.github.com/repos/sindresorhus/pure/pulls/149","_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/pure/pulls/comments/35477443"},"html":{"href":"https://github.com/sindresorhus/pure/pull/149#discussion_r35477443"},"pull_request":{"href":"https://api.github.com/repos/sindresorhus/pure/pulls/149"}}},"pull_request":{"url":"https://api.github.com/repos/sindresorhus/pure/pulls/149","id":40613539,"html_url":"https://github.com/sindresorhus/pure/pull/149","diff_url":"https://github.com/sindresorhus/pure/pull/149.diff","patch_url":"https://github.com/sindresorhus/pure/pull/149.patch","issue_url":"https://api.github.com/repos/sindresorhus/pure/issues/149","number":149,"state":"open","locked":false,"title":"Refactor to avoid subshell usage, prefer variables","user":{"login":"mafredri","id":147409,"avatar_url":"https://avatars.githubusercontent.com/u/147409?v=3","gravatar_id":"","url":"https://api.github.com/users/mafredri","html_url":"https://github.com/mafredri","followers_url":"https://api.github.com/users/mafredri/followers","following_url":"https://api.github.com/users/mafredri/following{/other_user}","gists_url":"https://api.github.com/users/mafredri/gists{/gist_id}","starred_url":"https://api.github.com/users/mafredri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mafredri/subscriptions","organizations_url":"https://api.github.com/users/mafredri/orgs","repos_url":"https://api.github.com/users/mafredri/repos","events_url":"https://api.github.com/users/mafredri/events{/privacy}","received_events_url":"https://api.github.com/users/mafredri/received_events","type":"User","site_admin":false},"body":"Performance tests indicated that using a lot of subshells can lead to bad performance as can be seen in [this gist](https://gist.github.com/mafredri/25aa77de809e86d24a63). I didn't want to change everything and hope it made anything better, so I decided to explore what this means in the real world for `pure` and performed some benchmarks.\r\n\r\nThe script I used for benchmarking can be found: [here](https://gist.github.com/mafredri/7625b223db6c2a1200f4)\r\n\r\n#### Results:\r\n\r\nTo be honest the speed wasn't bad enough for performance improvements to make much of a difference, but at least they are consistently better. Perhaps older systems and maybe even Windows would see better performance from these changes?\r\n\r\n##### Branches tested (in order):\r\n\r\n* master\r\n* pure-nitro (vcs_info) *[same as PR]*\r\n\t* Relies on vcs_info for current git working tree\r\n* pure-nitro (git)\r\n\t* Uses `command git rev-parse show-toplevel` for git tree (like master)\r\n\r\n##### 10,000 iterations\r\n\r\n```\r\nsum(field-1)\tmax(field-1)\tmin(field-1)\tmean(field-1)\tmedian(field-1)\r\n359.2467112505\t0.0578019619\t0.0319838524\t0.0359246711251\t0.03555846215\r\n225.164195295\t0.0337250233\t0.0200719833\t0.0225164195295\t0.0222561359\r\n258.7346487026\t0.0365149975\t0.0230011940\t0.0258734648703\t0.0255959034\r\n```\r\n\r\n**Median improvement:** 13.3 ms (master <> pure-nitro (vcs_info))\r\n\r\n##### 1,000 iteration + cpu stress\r\n\r\n```\r\nsum(field-1)\tmax(field-1)\tmin(field-1)\tmean(field-1)\tmedian(field-1)\r\n48.4606709483\t0.1176729202\t0.0320739746\t0.0484606709483\t0.0448194742\r\n30.9290690447\t0.0984218121\t0.0203421116\t0.0309290690447\t0.0280870199\r\n35.0805423275\t0.1091880798\t0.0235159397\t0.0350805423275\t0.0321009159\r\n```\r\n\r\n**Median improvement:** 16.7 ms (master <> pure-nitro (vcs_info))","created_at":"2015-07-22T21:25:01Z","updated_at":"2015-07-25T00:57:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8f7f9505cf7581b2d85fde131ac23dac3a4daa8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sindresorhus/pure/pulls/149/commits","review_comments_url":"https://api.github.com/repos/sindresorhus/pure/pulls/149/comments","review_comment_url":"https://api.github.com/repos/sindresorhus/pure/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sindresorhus/pure/issues/149/comments","statuses_url":"https://api.github.com/repos/sindresorhus/pure/statuses/b35b18a08a638d41ee11168b6d6a0231f76ca55a","head":{"label":"mafredri:pure-nitro","ref":"pure-nitro","sha":"b35b18a08a638d41ee11168b6d6a0231f76ca55a","user":{"login":"mafredri","id":147409,"avatar_url":"https://avatars.githubusercontent.com/u/147409?v=3","gravatar_id":"","url":"https://api.github.com/users/mafredri","html_url":"https://github.com/mafredri","followers_url":"https://api.github.com/users/mafredri/followers","following_url":"https://api.github.com/users/mafredri/following{/other_user}","gists_url":"https://api.github.com/users/mafredri/gists{/gist_id}","starred_url":"https://api.github.com/users/mafredri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mafredri/subscriptions","organizations_url":"https://api.github.com/users/mafredri/orgs","repos_url":"https://api.github.com/users/mafredri/repos","events_url":"https://api.github.com/users/mafredri/events{/privacy}","received_events_url":"https://api.github.com/users/mafredri/received_events","type":"User","site_admin":false},"repo":{"id":31123899,"name":"pure","full_name":"mafredri/pure","owner":{"login":"mafredri","id":147409,"avatar_url":"https://avatars.githubusercontent.com/u/147409?v=3","gravatar_id":"","url":"https://api.github.com/users/mafredri","html_url":"https://github.com/mafredri","followers_url":"https://api.github.com/users/mafredri/followers","following_url":"https://api.github.com/users/mafredri/following{/other_user}","gists_url":"https://api.github.com/users/mafredri/gists{/gist_id}","starred_url":"https://api.github.com/users/mafredri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mafredri/subscriptions","organizations_url":"https://api.github.com/users/mafredri/orgs","repos_url":"https://api.github.com/users/mafredri/repos","events_url":"https://api.github.com/users/mafredri/events{/privacy}","received_events_url":"https://api.github.com/users/mafredri/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mafredri/pure","description":"Pretty, minimal and fast ZSH prompt","fork":true,"url":"https://api.github.com/repos/mafredri/pure","forks_url":"https://api.github.com/repos/mafredri/pure/forks","keys_url":"https://api.github.com/repos/mafredri/pure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mafredri/pure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mafredri/pure/teams","hooks_url":"https://api.github.com/repos/mafredri/pure/hooks","issue_events_url":"https://api.github.com/repos/mafredri/pure/issues/events{/number}","events_url":"https://api.github.com/repos/mafredri/pure/events","assignees_url":"https://api.github.com/repos/mafredri/pure/assignees{/user}","branches_url":"https://api.github.com/repos/mafredri/pure/branches{/branch}","tags_url":"https://api.github.com/repos/mafredri/pure/tags","blobs_url":"https://api.github.com/repos/mafredri/pure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mafredri/pure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mafredri/pure/git/refs{/sha}","trees_url":"https://api.github.com/repos/mafredri/pure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mafredri/pure/statuses/{sha}","languages_url":"https://api.github.com/repos/mafredri/pure/languages","stargazers_url":"https://api.github.com/repos/mafredri/pure/stargazers","contributors_url":"https://api.github.com/repos/mafredri/pure/contributors","subscribers_url":"https://api.github.com/repos/mafredri/pure/subscribers","subscription_url":"https://api.github.com/repos/mafredri/pure/subscription","commits_url":"https://api.github.com/repos/mafredri/pure/commits{/sha}","git_commits_url":"https://api.github.com/repos/mafredri/pure/git/commits{/sha}","comments_url":"https://api.github.com/repos/mafredri/pure/comments{/number}","issue_comment_url":"https://api.github.com/repos/mafredri/pure/issues/comments{/number}","contents_url":"https://api.github.com/repos/mafredri/pure/contents/{+path}","compare_url":"https://api.github.com/repos/mafredri/pure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mafredri/pure/merges","archive_url":"https://api.github.com/repos/mafredri/pure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mafredri/pure/downloads","issues_url":"https://api.github.com/repos/mafredri/pure/issues{/number}","pulls_url":"https://api.github.com/repos/mafredri/pure/pulls{/number}","milestones_url":"https://api.github.com/repos/mafredri/pure/milestones{/number}","notifications_url":"https://api.github.com/repos/mafredri/pure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mafredri/pure/labels{/name}","releases_url":"https://api.github.com/repos/mafredri/pure/releases{/id}","created_at":"2015-02-21T11:46:12Z","updated_at":"2015-04-29T18:53:24Z","pushed_at":"2015-07-22T22:05:09Z","git_url":"git://github.com/mafredri/pure.git","ssh_url":"git@github.com:mafredri/pure.git","clone_url":"https://github.com/mafredri/pure.git","svn_url":"https://github.com/mafredri/pure","homepage":"","size":541,"stargazers_count":0,"watchers_count":0,"language":"Shell","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":"develop"}},"base":{"label":"sindresorhus:master","ref":"master","sha":"ba1f064357313201895505f658a18739dbb81be0","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"repo":{"id":5890857,"name":"pure","full_name":"sindresorhus/pure","owner":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sindresorhus/pure","description":"Pretty, minimal and fast ZSH prompt","fork":false,"url":"https://api.github.com/repos/sindresorhus/pure","forks_url":"https://api.github.com/repos/sindresorhus/pure/forks","keys_url":"https://api.github.com/repos/sindresorhus/pure/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sindresorhus/pure/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sindresorhus/pure/teams","hooks_url":"https://api.github.com/repos/sindresorhus/pure/hooks","issue_events_url":"https://api.github.com/repos/sindresorhus/pure/issues/events{/number}","events_url":"https://api.github.com/repos/sindresorhus/pure/events","assignees_url":"https://api.github.com/repos/sindresorhus/pure/assignees{/user}","branches_url":"https://api.github.com/repos/sindresorhus/pure/branches{/branch}","tags_url":"https://api.github.com/repos/sindresorhus/pure/tags","blobs_url":"https://api.github.com/repos/sindresorhus/pure/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sindresorhus/pure/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sindresorhus/pure/git/refs{/sha}","trees_url":"https://api.github.com/repos/sindresorhus/pure/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sindresorhus/pure/statuses/{sha}","languages_url":"https://api.github.com/repos/sindresorhus/pure/languages","stargazers_url":"https://api.github.com/repos/sindresorhus/pure/stargazers","contributors_url":"https://api.github.com/repos/sindresorhus/pure/contributors","subscribers_url":"https://api.github.com/repos/sindresorhus/pure/subscribers","subscription_url":"https://api.github.com/repos/sindresorhus/pure/subscription","commits_url":"https://api.github.com/repos/sindresorhus/pure/commits{/sha}","git_commits_url":"https://api.github.com/repos/sindresorhus/pure/git/commits{/sha}","comments_url":"https://api.github.com/repos/sindresorhus/pure/comments{/number}","issue_comment_url":"https://api.github.com/repos/sindresorhus/pure/issues/comments{/number}","contents_url":"https://api.github.com/repos/sindresorhus/pure/contents/{+path}","compare_url":"https://api.github.com/repos/sindresorhus/pure/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sindresorhus/pure/merges","archive_url":"https://api.github.com/repos/sindresorhus/pure/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sindresorhus/pure/downloads","issues_url":"https://api.github.com/repos/sindresorhus/pure/issues{/number}","pulls_url":"https://api.github.com/repos/sindresorhus/pure/pulls{/number}","milestones_url":"https://api.github.com/repos/sindresorhus/pure/milestones{/number}","notifications_url":"https://api.github.com/repos/sindresorhus/pure/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sindresorhus/pure/labels{/name}","releases_url":"https://api.github.com/repos/sindresorhus/pure/releases{/id}","created_at":"2012-09-20T18:14:58Z","updated_at":"2015-07-24T11:16:55Z","pushed_at":"2015-07-23T05:58:11Z","git_url":"git://github.com/sindresorhus/pure.git","ssh_url":"git@github.com:sindresorhus/pure.git","clone_url":"https://github.com/sindresorhus/pure.git","svn_url":"https://github.com/sindresorhus/pure","homepage":"","size":1190,"stargazers_count":1271,"watchers_count":1271,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":8,"forks":156,"open_issues":8,"watchers":1271,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/pure/pulls/149"},"html":{"href":"https://github.com/sindresorhus/pure/pull/149"},"issue":{"href":"https://api.github.com/repos/sindresorhus/pure/issues/149"},"comments":{"href":"https://api.github.com/repos/sindresorhus/pure/issues/149/comments"},"review_comments":{"href":"https://api.github.com/repos/sindresorhus/pure/pulls/149/comments"},"review_comment":{"href":"https://api.github.com/repos/sindresorhus/pure/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sindresorhus/pure/pulls/149/commits"},"statuses":{"href":"https://api.github.com/repos/sindresorhus/pure/statuses/b35b18a08a638d41ee11168b6d6a0231f76ca55a"}}}}