{"action":"created","comment":{"url":"https://api.github.com/repos/minio/minio/pulls/comments/60628325","id":60628325,"diff_hunk":"@@ -118,25 +118,21 @@ func checkDiskFree(diskPath string, minFreeDisk int64) (err error) {\n \treturn nil\n }\n \n-// removeDuplicateVols - remove duplicate volumes.\n-func removeDuplicateVols(vols []VolInfo) []VolInfo {\n-\tlength := len(vols) - 1\n-\tfor i := 0; i < length; i++ {\n-\t\tfor j := i + 1; j <= length; j++ {\n-\t\t\tif vols[i].Name == vols[j].Name {\n-\t\t\t\t// Pick the latest volume, if there is a duplicate.\n-\t\t\t\tif vols[i].Created.Sub(vols[j].Created) > 0 {\n-\t\t\t\t\tvols[i] = vols[length]\n-\t\t\t\t} else {\n-\t\t\t\t\tvols[j] = vols[length]\n-\t\t\t\t}\n-\t\t\t\tvols = vols[0:length]\n-\t\t\t\tlength--\n-\t\t\t\tj--\n-\t\t\t}\n+func removeDuplicateVols(volsInfo []VolInfo) []VolInfo {\n+\t// Use map to record duplicates as we find them.\n+\tencountered := make(map[string]bool)\n+\tresult := []VolInfo{}\n+\n+\tfor i := range volsInfo {\n+\t\tif !encountered[volsInfo[i].Name] {\n+\t\t\t// Record this element as an encountered element.\n+\t\t\tencountered[volsInfo[i].Name] = true\n+\t\t\t// Append to result slice.\n+\t\t\tresult = append(result, volsInfo[i])\n \t\t}\n \t}\n-\treturn vols\n+\t// Return the new slice.\n+\treturn result\n }","path":"fs.go","position":36,"original_position":36,"commit_id":"2f8bb94459db4d3b141992b3f22b7185f6b62257","original_commit_id":"2f8bb94459db4d3b141992b3f22b7185f6b62257","user":{"login":"harshavardhana","id":622699,"avatar_url":"https://avatars.githubusercontent.com/u/622699?v=3","gravatar_id":"","url":"https://api.github.com/users/harshavardhana","html_url":"https://github.com/harshavardhana","followers_url":"https://api.github.com/users/harshavardhana/followers","following_url":"https://api.github.com/users/harshavardhana/following{/other_user}","gists_url":"https://api.github.com/users/harshavardhana/gists{/gist_id}","starred_url":"https://api.github.com/users/harshavardhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshavardhana/subscriptions","organizations_url":"https://api.github.com/users/harshavardhana/orgs","repos_url":"https://api.github.com/users/harshavardhana/repos","events_url":"https://api.github.com/users/harshavardhana/events{/privacy}","received_events_url":"https://api.github.com/users/harshavardhana/received_events","type":"User","site_admin":false},"body":"> m := make(map[string]VolInfo)\r\n> for _, v := range volsInfo {\r\n>     if _, found := m[v.Name]; !found {\r\n>         m[v.Name] = v\r\n>     }\r\n> }\r\n> \r\n> result := make([]VolInfo, 0, len(m))\r\n> for _, v := range m {\r\n>     result = append(result, v)\r\n> }\r\n\r\nThis correct one, we had this before before moving to slice. Looping is fine. ","created_at":"2016-04-21T18:06:38Z","updated_at":"2016-04-21T18:06:38Z","html_url":"https://github.com/minio/minio/pull/1344#discussion_r60628325","pull_request_url":"https://api.github.com/repos/minio/minio/pulls/1344","_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/comments/60628325"},"html":{"href":"https://github.com/minio/minio/pull/1344#discussion_r60628325"},"pull_request":{"href":"https://api.github.com/repos/minio/minio/pulls/1344"}}},"pull_request":{"url":"https://api.github.com/repos/minio/minio/pulls/1344","id":67281260,"html_url":"https://github.com/minio/minio/pull/1344","diff_url":"https://github.com/minio/minio/pull/1344.diff","patch_url":"https://github.com/minio/minio/pull/1344.patch","issue_url":"https://api.github.com/repos/minio/minio/issues/1344","number":1344,"state":"open","locked":false,"title":"xl: Handle read quorum for StatVol, ListVols","user":{"login":"harshavardhana","id":622699,"avatar_url":"https://avatars.githubusercontent.com/u/622699?v=3","gravatar_id":"","url":"https://api.github.com/users/harshavardhana","html_url":"https://github.com/harshavardhana","followers_url":"https://api.github.com/users/harshavardhana/followers","following_url":"https://api.github.com/users/harshavardhana/following{/other_user}","gists_url":"https://api.github.com/users/harshavardhana/gists{/gist_id}","starred_url":"https://api.github.com/users/harshavardhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshavardhana/subscriptions","organizations_url":"https://api.github.com/users/harshavardhana/orgs","repos_url":"https://api.github.com/users/harshavardhana/repos","events_url":"https://api.github.com/users/harshavardhana/events{/privacy}","received_events_url":"https://api.github.com/users/harshavardhana/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-21T00:50:46Z","updated_at":"2016-04-21T18:06:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39ebcb4f376a34cb74c00d490122a4acc6c55df3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/minio/minio/pulls/1344/commits","review_comments_url":"https://api.github.com/repos/minio/minio/pulls/1344/comments","review_comment_url":"https://api.github.com/repos/minio/minio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minio/minio/issues/1344/comments","statuses_url":"https://api.github.com/repos/minio/minio/statuses/2f8bb94459db4d3b141992b3f22b7185f6b62257","head":{"label":"harshavardhana:xl-layer-mod","ref":"xl-layer-mod","sha":"2f8bb94459db4d3b141992b3f22b7185f6b62257","user":{"login":"harshavardhana","id":622699,"avatar_url":"https://avatars.githubusercontent.com/u/622699?v=3","gravatar_id":"","url":"https://api.github.com/users/harshavardhana","html_url":"https://github.com/harshavardhana","followers_url":"https://api.github.com/users/harshavardhana/followers","following_url":"https://api.github.com/users/harshavardhana/following{/other_user}","gists_url":"https://api.github.com/users/harshavardhana/gists{/gist_id}","starred_url":"https://api.github.com/users/harshavardhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshavardhana/subscriptions","organizations_url":"https://api.github.com/users/harshavardhana/orgs","repos_url":"https://api.github.com/users/harshavardhana/repos","events_url":"https://api.github.com/users/harshavardhana/events{/privacy}","received_events_url":"https://api.github.com/users/harshavardhana/received_events","type":"User","site_admin":false},"repo":{"id":29261868,"name":"minio","full_name":"harshavardhana/minio","owner":{"login":"harshavardhana","id":622699,"avatar_url":"https://avatars.githubusercontent.com/u/622699?v=3","gravatar_id":"","url":"https://api.github.com/users/harshavardhana","html_url":"https://github.com/harshavardhana","followers_url":"https://api.github.com/users/harshavardhana/followers","following_url":"https://api.github.com/users/harshavardhana/following{/other_user}","gists_url":"https://api.github.com/users/harshavardhana/gists{/gist_id}","starred_url":"https://api.github.com/users/harshavardhana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshavardhana/subscriptions","organizations_url":"https://api.github.com/users/harshavardhana/orgs","repos_url":"https://api.github.com/users/harshavardhana/repos","events_url":"https://api.github.com/users/harshavardhana/events{/privacy}","received_events_url":"https://api.github.com/users/harshavardhana/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/harshavardhana/minio","description":"Minio is open source Object Storage inspired from Amazon S3 API and Haystack Object Format","fork":true,"url":"https://api.github.com/repos/harshavardhana/minio","forks_url":"https://api.github.com/repos/harshavardhana/minio/forks","keys_url":"https://api.github.com/repos/harshavardhana/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harshavardhana/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harshavardhana/minio/teams","hooks_url":"https://api.github.com/repos/harshavardhana/minio/hooks","issue_events_url":"https://api.github.com/repos/harshavardhana/minio/issues/events{/number}","events_url":"https://api.github.com/repos/harshavardhana/minio/events","assignees_url":"https://api.github.com/repos/harshavardhana/minio/assignees{/user}","branches_url":"https://api.github.com/repos/harshavardhana/minio/branches{/branch}","tags_url":"https://api.github.com/repos/harshavardhana/minio/tags","blobs_url":"https://api.github.com/repos/harshavardhana/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harshavardhana/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harshavardhana/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/harshavardhana/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harshavardhana/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/harshavardhana/minio/languages","stargazers_url":"https://api.github.com/repos/harshavardhana/minio/stargazers","contributors_url":"https://api.github.com/repos/harshavardhana/minio/contributors","subscribers_url":"https://api.github.com/repos/harshavardhana/minio/subscribers","subscription_url":"https://api.github.com/repos/harshavardhana/minio/subscription","commits_url":"https://api.github.com/repos/harshavardhana/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/harshavardhana/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/harshavardhana/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/harshavardhana/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/harshavardhana/minio/contents/{+path}","compare_url":"https://api.github.com/repos/harshavardhana/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harshavardhana/minio/merges","archive_url":"https://api.github.com/repos/harshavardhana/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harshavardhana/minio/downloads","issues_url":"https://api.github.com/repos/harshavardhana/minio/issues{/number}","pulls_url":"https://api.github.com/repos/harshavardhana/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/harshavardhana/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/harshavardhana/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harshavardhana/minio/labels{/name}","releases_url":"https://api.github.com/repos/harshavardhana/minio/releases{/id}","deployments_url":"https://api.github.com/repos/harshavardhana/minio/deployments","created_at":"2015-01-14T19:32:24Z","updated_at":"2015-11-03T05:50:43Z","pushed_at":"2016-04-21T08:32:52Z","git_url":"git://github.com/harshavardhana/minio.git","ssh_url":"git@github.com:harshavardhana/minio.git","clone_url":"https://github.com/harshavardhana/minio.git","svn_url":"https://github.com/harshavardhana/minio","homepage":"http://minio.io","size":12428,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"pr_out_minio_dl_minio_io_changes_do_not_merge_until_webcli"}},"base":{"label":"minio:xl-layer","ref":"xl-layer","sha":"a62cdf31bf257212ca40dd659e8a471c449b2979","user":{"login":"minio","id":695951,"avatar_url":"https://avatars.githubusercontent.com/u/695951?v=3","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"repo":{"id":29261473,"name":"minio","full_name":"minio/minio","owner":{"login":"minio","id":695951,"avatar_url":"https://avatars.githubusercontent.com/u/695951?v=3","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minio/minio","description":"Minio is an object storage server compatible with Amazon S3 and licensed under Apache 2.0 License","fork":false,"url":"https://api.github.com/repos/minio/minio","forks_url":"https://api.github.com/repos/minio/minio/forks","keys_url":"https://api.github.com/repos/minio/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minio/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minio/minio/teams","hooks_url":"https://api.github.com/repos/minio/minio/hooks","issue_events_url":"https://api.github.com/repos/minio/minio/issues/events{/number}","events_url":"https://api.github.com/repos/minio/minio/events","assignees_url":"https://api.github.com/repos/minio/minio/assignees{/user}","branches_url":"https://api.github.com/repos/minio/minio/branches{/branch}","tags_url":"https://api.github.com/repos/minio/minio/tags","blobs_url":"https://api.github.com/repos/minio/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minio/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minio/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/minio/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minio/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/minio/minio/languages","stargazers_url":"https://api.github.com/repos/minio/minio/stargazers","contributors_url":"https://api.github.com/repos/minio/minio/contributors","subscribers_url":"https://api.github.com/repos/minio/minio/subscribers","subscription_url":"https://api.github.com/repos/minio/minio/subscription","commits_url":"https://api.github.com/repos/minio/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/minio/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/minio/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/minio/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/minio/minio/contents/{+path}","compare_url":"https://api.github.com/repos/minio/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minio/minio/merges","archive_url":"https://api.github.com/repos/minio/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minio/minio/downloads","issues_url":"https://api.github.com/repos/minio/minio/issues{/number}","pulls_url":"https://api.github.com/repos/minio/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/minio/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/minio/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minio/minio/labels{/name}","releases_url":"https://api.github.com/repos/minio/minio/releases{/id}","deployments_url":"https://api.github.com/repos/minio/minio/deployments","created_at":"2015-01-14T19:23:58Z","updated_at":"2016-04-21T17:22:16Z","pushed_at":"2016-04-21T15:16:16Z","git_url":"git://github.com/minio/minio.git","ssh_url":"git@github.com:minio/minio.git","clone_url":"https://github.com/minio/minio.git","svn_url":"https://github.com/minio/minio","homepage":"https://minio.io/download/","size":13515,"stargazers_count":1088,"watchers_count":1088,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":30,"forks":103,"open_issues":30,"watchers":1088,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/1344"},"html":{"href":"https://github.com/minio/minio/pull/1344"},"issue":{"href":"https://api.github.com/repos/minio/minio/issues/1344"},"comments":{"href":"https://api.github.com/repos/minio/minio/issues/1344/comments"},"review_comments":{"href":"https://api.github.com/repos/minio/minio/pulls/1344/comments"},"review_comment":{"href":"https://api.github.com/repos/minio/minio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minio/minio/pulls/1344/commits"},"statuses":{"href":"https://api.github.com/repos/minio/minio/statuses/2f8bb94459db4d3b141992b3f22b7185f6b62257"}}}}