{"action":"created","comment":{"url":"https://api.github.com/repos/apple/swift-nio/pulls/comments/183639400","pull_request_review_id":114672856,"id":183639400,"diff_hunk":"@@ -50,36 +50,63 @@ public struct CircularBuffer<E>: CustomStringConvertible, AppendableCollection {\n     ///\n     /// Amortized *O(1)*\n     public mutating func append(_ value: E) {\n+        return self.addLast(value)\n+    }\n+\n+    /// Add an element to the end of the ring buffer.\n+    ///\n+    /// Amortized *O(1)*\n+    public mutating func addLast(_ value: E) {\n         self.buffer[self.tailIdx] = value\n         self.tailIdx = (self.tailIdx + 1) & self.mask\n \n         if self.headIdx == self.tailIdx {\n             // No more room left for another append so grow the buffer now.\n-            var newBacking: ContiguousArray<E?> = []\n-            let newCapacity = self.buffer.count << 1 // Double the storage.\n-            precondition(newCapacity > 0, \"Can't double capacity of \\(self.buffer.count)\")\n-            assert(newCapacity % 2 == 0)\n-\n-            newBacking.reserveCapacity(newCapacity)\n-            newBacking.append(contentsOf: self.buffer[self.headIdx..<self.buffer.count])\n-            if self.headIdx > 0 {\n-                newBacking.append(contentsOf: self.buffer[0..<self.headIdx])\n-            }\n-            newBacking.append(contentsOf: repeatElement(nil, count: newCapacity - newBacking.count))\n-            self.tailIdx = self.buffer.count\n-            self.headIdx = 0\n-            self.buffer = newBacking\n+            self.doubleCapacity()\n+        }\n+    }\n+\n+    /// Add an element to the front of the ring buffer.\n+    ///\n+    /// Amortized *O(1)*\n+    public mutating func addFirst(_ value: E) {","path":"Sources/NIO/CircularBuffer.swift","position":null,"original_position":37,"commit_id":"2b8a19557c9c6f11b50e5aa40c669b9c9db4af13","original_commit_id":"198528428e942abe7a2abda529f433934661e941","user":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars3.githubusercontent.com/u/439362?v=4","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"body":"@weissi sounds good to me... That said I think we can pull in the PR as it is now... WDYT ?","created_at":"2018-04-24T08:09:20Z","updated_at":"2018-04-24T08:09:21Z","html_url":"https://github.com/apple/swift-nio/pull/347#discussion_r183639400","pull_request_url":"https://api.github.com/repos/apple/swift-nio/pulls/347","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/comments/183639400"},"html":{"href":"https://github.com/apple/swift-nio/pull/347#discussion_r183639400"},"pull_request":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/347"}},"in_reply_to_id":183440334},"pull_request":{"url":"https://api.github.com/repos/apple/swift-nio/pulls/347","id":183390485,"html_url":"https://github.com/apple/swift-nio/pull/347","diff_url":"https://github.com/apple/swift-nio/pull/347.diff","patch_url":"https://github.com/apple/swift-nio/pull/347.patch","issue_url":"https://api.github.com/repos/apple/swift-nio/issues/347","number":347,"state":"open","locked":false,"title":"Add last / addFirst to CircularBuffer","user":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars3.githubusercontent.com/u/439362?v=4","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nIts often useful to be able to add / retrieve elements on both sides of a CircularBuffer.\r\n\r\nModifications:\r\n\r\n- Add last / addFirst to be able to act on both ends.\r\n- Add tests\r\n\r\nResult:\r\n\r\nFixes https://github.com/apple/swift-nio/issues/279","created_at":"2018-04-23T10:30:02Z","updated_at":"2018-04-24T08:09:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e27e7a345d82aad3cafea0ad71407a40176bbd5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":844994002,"url":"https://api.github.com/repos/apple/swift-nio/labels/needs-minor-version-bump","name":"needs-minor-version-bump","color":"CE32BC","default":false}],"milestone":{"url":"https://api.github.com/repos/apple/swift-nio/milestones/12","html_url":"https://github.com/apple/swift-nio/milestone/12","labels_url":"https://api.github.com/repos/apple/swift-nio/milestones/12/labels","id":3288800,"number":12,"title":"1.6.0","description":null,"creator":{"login":"Lukasa","id":1382556,"avatar_url":"https://avatars1.githubusercontent.com/u/1382556?v=4","gravatar_id":"","url":"https://api.github.com/users/Lukasa","html_url":"https://github.com/Lukasa","followers_url":"https://api.github.com/users/Lukasa/followers","following_url":"https://api.github.com/users/Lukasa/following{/other_user}","gists_url":"https://api.github.com/users/Lukasa/gists{/gist_id}","starred_url":"https://api.github.com/users/Lukasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lukasa/subscriptions","organizations_url":"https://api.github.com/users/Lukasa/orgs","repos_url":"https://api.github.com/users/Lukasa/repos","events_url":"https://api.github.com/users/Lukasa/events{/privacy}","received_events_url":"https://api.github.com/users/Lukasa/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":4,"state":"open","created_at":"2018-04-23T09:47:09Z","updated_at":"2018-04-24T07:18:22Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/apple/swift-nio/pulls/347/commits","review_comments_url":"https://api.github.com/repos/apple/swift-nio/pulls/347/comments","review_comment_url":"https://api.github.com/repos/apple/swift-nio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apple/swift-nio/issues/347/comments","statuses_url":"https://api.github.com/repos/apple/swift-nio/statuses/2b8a19557c9c6f11b50e5aa40c669b9c9db4af13","head":{"label":"normanmaurer:deque","ref":"deque","sha":"2b8a19557c9c6f11b50e5aa40c669b9c9db4af13","user":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars3.githubusercontent.com/u/439362?v=4","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"repo":{"id":123526297,"name":"swift-nio","full_name":"normanmaurer/swift-nio","owner":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars3.githubusercontent.com/u/439362?v=4","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/normanmaurer/swift-nio","description":"Event-driven network application framework for high performance protocol servers & clients, non-blocking.","fork":true,"url":"https://api.github.com/repos/normanmaurer/swift-nio","forks_url":"https://api.github.com/repos/normanmaurer/swift-nio/forks","keys_url":"https://api.github.com/repos/normanmaurer/swift-nio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/normanmaurer/swift-nio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/normanmaurer/swift-nio/teams","hooks_url":"https://api.github.com/repos/normanmaurer/swift-nio/hooks","issue_events_url":"https://api.github.com/repos/normanmaurer/swift-nio/issues/events{/number}","events_url":"https://api.github.com/repos/normanmaurer/swift-nio/events","assignees_url":"https://api.github.com/repos/normanmaurer/swift-nio/assignees{/user}","branches_url":"https://api.github.com/repos/normanmaurer/swift-nio/branches{/branch}","tags_url":"https://api.github.com/repos/normanmaurer/swift-nio/tags","blobs_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/refs{/sha}","trees_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/normanmaurer/swift-nio/statuses/{sha}","languages_url":"https://api.github.com/repos/normanmaurer/swift-nio/languages","stargazers_url":"https://api.github.com/repos/normanmaurer/swift-nio/stargazers","contributors_url":"https://api.github.com/repos/normanmaurer/swift-nio/contributors","subscribers_url":"https://api.github.com/repos/normanmaurer/swift-nio/subscribers","subscription_url":"https://api.github.com/repos/normanmaurer/swift-nio/subscription","commits_url":"https://api.github.com/repos/normanmaurer/swift-nio/commits{/sha}","git_commits_url":"https://api.github.com/repos/normanmaurer/swift-nio/git/commits{/sha}","comments_url":"https://api.github.com/repos/normanmaurer/swift-nio/comments{/number}","issue_comment_url":"https://api.github.com/repos/normanmaurer/swift-nio/issues/comments{/number}","contents_url":"https://api.github.com/repos/normanmaurer/swift-nio/contents/{+path}","compare_url":"https://api.github.com/repos/normanmaurer/swift-nio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/normanmaurer/swift-nio/merges","archive_url":"https://api.github.com/repos/normanmaurer/swift-nio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/normanmaurer/swift-nio/downloads","issues_url":"https://api.github.com/repos/normanmaurer/swift-nio/issues{/number}","pulls_url":"https://api.github.com/repos/normanmaurer/swift-nio/pulls{/number}","milestones_url":"https://api.github.com/repos/normanmaurer/swift-nio/milestones{/number}","notifications_url":"https://api.github.com/repos/normanmaurer/swift-nio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/normanmaurer/swift-nio/labels{/name}","releases_url":"https://api.github.com/repos/normanmaurer/swift-nio/releases{/id}","deployments_url":"https://api.github.com/repos/normanmaurer/swift-nio/deployments","created_at":"2018-03-02T03:37:41Z","updated_at":"2018-04-23T19:20:17Z","pushed_at":"2018-04-24T07:22:14Z","git_url":"git://github.com/normanmaurer/swift-nio.git","ssh_url":"git@github.com:normanmaurer/swift-nio.git","clone_url":"https://github.com/normanmaurer/swift-nio.git","svn_url":"https://github.com/normanmaurer/swift-nio","homepage":"","size":3310,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apple:master","ref":"master","sha":"ec30e5cc5a90a7da59a284971127a822a0aa9663","user":{"login":"apple","id":10639145,"avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"repo":{"id":120498971,"name":"swift-nio","full_name":"apple/swift-nio","owner":{"login":"apple","id":10639145,"avatar_url":"https://avatars0.githubusercontent.com/u/10639145?v=4","gravatar_id":"","url":"https://api.github.com/users/apple","html_url":"https://github.com/apple","followers_url":"https://api.github.com/users/apple/followers","following_url":"https://api.github.com/users/apple/following{/other_user}","gists_url":"https://api.github.com/users/apple/gists{/gist_id}","starred_url":"https://api.github.com/users/apple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apple/subscriptions","organizations_url":"https://api.github.com/users/apple/orgs","repos_url":"https://api.github.com/users/apple/repos","events_url":"https://api.github.com/users/apple/events{/privacy}","received_events_url":"https://api.github.com/users/apple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apple/swift-nio","description":"Event-driven network application framework for high performance protocol servers & clients, non-blocking.","fork":false,"url":"https://api.github.com/repos/apple/swift-nio","forks_url":"https://api.github.com/repos/apple/swift-nio/forks","keys_url":"https://api.github.com/repos/apple/swift-nio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apple/swift-nio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apple/swift-nio/teams","hooks_url":"https://api.github.com/repos/apple/swift-nio/hooks","issue_events_url":"https://api.github.com/repos/apple/swift-nio/issues/events{/number}","events_url":"https://api.github.com/repos/apple/swift-nio/events","assignees_url":"https://api.github.com/repos/apple/swift-nio/assignees{/user}","branches_url":"https://api.github.com/repos/apple/swift-nio/branches{/branch}","tags_url":"https://api.github.com/repos/apple/swift-nio/tags","blobs_url":"https://api.github.com/repos/apple/swift-nio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apple/swift-nio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apple/swift-nio/git/refs{/sha}","trees_url":"https://api.github.com/repos/apple/swift-nio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apple/swift-nio/statuses/{sha}","languages_url":"https://api.github.com/repos/apple/swift-nio/languages","stargazers_url":"https://api.github.com/repos/apple/swift-nio/stargazers","contributors_url":"https://api.github.com/repos/apple/swift-nio/contributors","subscribers_url":"https://api.github.com/repos/apple/swift-nio/subscribers","subscription_url":"https://api.github.com/repos/apple/swift-nio/subscription","commits_url":"https://api.github.com/repos/apple/swift-nio/commits{/sha}","git_commits_url":"https://api.github.com/repos/apple/swift-nio/git/commits{/sha}","comments_url":"https://api.github.com/repos/apple/swift-nio/comments{/number}","issue_comment_url":"https://api.github.com/repos/apple/swift-nio/issues/comments{/number}","contents_url":"https://api.github.com/repos/apple/swift-nio/contents/{+path}","compare_url":"https://api.github.com/repos/apple/swift-nio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apple/swift-nio/merges","archive_url":"https://api.github.com/repos/apple/swift-nio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apple/swift-nio/downloads","issues_url":"https://api.github.com/repos/apple/swift-nio/issues{/number}","pulls_url":"https://api.github.com/repos/apple/swift-nio/pulls{/number}","milestones_url":"https://api.github.com/repos/apple/swift-nio/milestones{/number}","notifications_url":"https://api.github.com/repos/apple/swift-nio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apple/swift-nio/labels{/name}","releases_url":"https://api.github.com/repos/apple/swift-nio/releases{/id}","deployments_url":"https://api.github.com/repos/apple/swift-nio/deployments","created_at":"2018-02-06T17:47:31Z","updated_at":"2018-04-24T07:18:27Z","pushed_at":"2018-04-24T07:22:16Z","git_url":"git://github.com/apple/swift-nio.git","ssh_url":"git@github.com:apple/swift-nio.git","clone_url":"https://github.com/apple/swift-nio.git","svn_url":"https://github.com/apple/swift-nio","homepage":"","size":6394,"stargazers_count":3494,"watchers_count":3494,"language":"Swift","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":141,"mirror_url":null,"archived":false,"open_issues_count":50,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":141,"open_issues":50,"watchers":3494,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/347"},"html":{"href":"https://github.com/apple/swift-nio/pull/347"},"issue":{"href":"https://api.github.com/repos/apple/swift-nio/issues/347"},"comments":{"href":"https://api.github.com/repos/apple/swift-nio/issues/347/comments"},"review_comments":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/347/comments"},"review_comment":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apple/swift-nio/pulls/347/commits"},"statuses":{"href":"https://api.github.com/repos/apple/swift-nio/statuses/2b8a19557c9c6f11b50e5aa40c669b9c9db4af13"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"normanmaurer"}}