{"action":"created","comment":{"url":"https://api.github.com/repos/qutheory/vapor/pulls/comments/66559810","id":66559810,"diff_hunk":"@@ -0,0 +1,160 @@\n+extension Data {\n+    func split(separator: Data, excludingFirst: Bool = false, excludingLast: Bool = false, maxSplits: Int? = nil) -> [Data] {\n+        var ranges = [(from: Int, to: Int)]()\n+        var parts = [Data]()\n+\n+        // \"\\r\\n\\r\\n\\r\\n\".split(separator: \"\\r\\n\\r\\n\") would break without this because it occurs twice in the same place\n+        var highestOccurence = -1\n+\n+        // Find occurences of boundries\n+        for (index, element) in self.enumerated() where index > highestOccurence && !(maxSplits != nil && ranges.count >= maxSplits) {\n+            // If this first element matches and there are enough bytes left\n+            guard element == separator.first && self.count >= index + separator.count else {\n+                continue\n+            }\n+\n+            // Take the last byte of where the end of the separator would be and check it\n+            guard self[index + separator.count - 1] == separator.bytes.last else {\n+                continue\n+            }\n+\n+            // Check if this range matches (put separately for efficiency)\n+            guard Data(self[index..<(index+separator.count)]) == separator else {\n+                continue\n+            }\n+            \n+            // Append the range of the separator\n+            ranges.append((index, index + separator.count))\n+\n+            // Increase the highest occurrence to prevent a crash as described above\n+            highestOccurence = index + separator.count\n+        }\n+\n+        // The first data (before the first separator)\n+        if let firstRange = ranges.first where !excludingFirst {\n+            parts.append(Data(self[0..<firstRange.from]))\n+        }\n+\n+        // Loop over the ranges\n+        for (pos, range) in ranges.enumerated() {\n+            // If this is before the last separator\n+            if pos < ranges.count - 1 {\n+                // Take the data inbetween this and the next boundry\n+                let nextRange = ranges[pos + 1]\n+\n+                parts.append(Data(self[range.to..<nextRange.from]))\n+\n+            // If this is after the last separator and shouldn't be thrown away\n+            } else if ranges[ranges.count - 1].to < self.count && !excludingLast {\n+                parts.append(Data(self[range.to..<self.count]))\n+            }\n+        }\n+\n+        return parts\n+    }\n+}\n+\n+extension Byte {\n+    struct ASCII {","path":"Sources/Vapor/Utilities/Vapor+Data.swift","position":58,"original_position":58,"commit_id":"f5b6fbab353d38d7edfab0d365956b64ce90e1b1","original_commit_id":"f5b6fbab353d38d7edfab0d365956b64ce90e1b1","user":{"login":"tannernelson","id":1342803,"avatar_url":"https://avatars.githubusercontent.com/u/1342803?v=3","gravatar_id":"","url":"https://api.github.com/users/tannernelson","html_url":"https://github.com/tannernelson","followers_url":"https://api.github.com/users/tannernelson/followers","following_url":"https://api.github.com/users/tannernelson/following{/other_user}","gists_url":"https://api.github.com/users/tannernelson/gists{/gist_id}","starred_url":"https://api.github.com/users/tannernelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tannernelson/subscriptions","organizations_url":"https://api.github.com/users/tannernelson/orgs","repos_url":"https://api.github.com/users/tannernelson/repos","events_url":"https://api.github.com/users/tannernelson/events{/privacy}","received_events_url":"https://api.github.com/users/tannernelson/received_events","type":"User","site_admin":false},"body":"I originally had them on Byte, but I moved it after adding `firstValidCharacter` because Byte.firstValidCharacter did not make as much sense as Byte.ASCII.firstValidCharacter (for the nextLine function on the HTTPParser).\r\n\r\nBut I think that has been changed now to just be\r\n`if byte > Byte.ASCII.carriageReturn`. So that shouldn't be an issue anymore. \r\n\r\nI was also considering the impact that charsets would have, but I don't think that should affect anything related to parsing or serializing of the HTTP message. Charsets should only deal with the message body which should be handled by middleware. ","created_at":"2016-06-10T04:15:43Z","updated_at":"2016-06-10T04:15:43Z","html_url":"https://github.com/qutheory/vapor/pull/374#discussion_r66559810","pull_request_url":"https://api.github.com/repos/qutheory/vapor/pulls/374","_links":{"self":{"href":"https://api.github.com/repos/qutheory/vapor/pulls/comments/66559810"},"html":{"href":"https://github.com/qutheory/vapor/pull/374#discussion_r66559810"},"pull_request":{"href":"https://api.github.com/repos/qutheory/vapor/pulls/374"}}},"pull_request":{"url":"https://api.github.com/repos/qutheory/vapor/pulls/374","id":73261719,"html_url":"https://github.com/qutheory/vapor/pull/374","diff_url":"https://github.com/qutheory/vapor/pull/374.diff","patch_url":"https://github.com/qutheory/vapor/pull/374.patch","issue_url":"https://api.github.com/repos/qutheory/vapor/issues/374","number":374,"state":"open","locked":false,"title":"Performance improvements","user":{"login":"Joannis","id":1951674,"avatar_url":"https://avatars.githubusercontent.com/u/1951674?v=3","gravatar_id":"","url":"https://api.github.com/users/Joannis","html_url":"https://github.com/Joannis","followers_url":"https://api.github.com/users/Joannis/followers","following_url":"https://api.github.com/users/Joannis/following{/other_user}","gists_url":"https://api.github.com/users/Joannis/gists{/gist_id}","starred_url":"https://api.github.com/users/Joannis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Joannis/subscriptions","organizations_url":"https://api.github.com/users/Joannis/orgs","repos_url":"https://api.github.com/users/Joannis/repos","events_url":"https://api.github.com/users/Joannis/events{/privacy}","received_events_url":"https://api.github.com/users/Joannis/received_events","type":"User","site_admin":false},"body":"Improved the performance by not using strings internally. Needs a bit of cleanup, comments and it uses quite a few constants that should be grouped properly","created_at":"2016-06-09T18:22:15Z","updated_at":"2016-06-10T04:15:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"de3569e88daf94012ae58a4ec2e283a03a3fc815","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/qutheory/vapor/pulls/374/commits","review_comments_url":"https://api.github.com/repos/qutheory/vapor/pulls/374/comments","review_comment_url":"https://api.github.com/repos/qutheory/vapor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/qutheory/vapor/issues/374/comments","statuses_url":"https://api.github.com/repos/qutheory/vapor/statuses/f5b6fbab353d38d7edfab0d365956b64ce90e1b1","head":{"label":"qutheory:performance","ref":"performance","sha":"f5b6fbab353d38d7edfab0d365956b64ce90e1b1","user":{"login":"qutheory","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/qutheory","html_url":"https://github.com/qutheory","followers_url":"https://api.github.com/users/qutheory/followers","following_url":"https://api.github.com/users/qutheory/following{/other_user}","gists_url":"https://api.github.com/users/qutheory/gists{/gist_id}","starred_url":"https://api.github.com/users/qutheory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qutheory/subscriptions","organizations_url":"https://api.github.com/users/qutheory/orgs","repos_url":"https://api.github.com/users/qutheory/repos","events_url":"https://api.github.com/users/qutheory/events{/privacy}","received_events_url":"https://api.github.com/users/qutheory/received_events","type":"Organization","site_admin":false},"repo":{"id":49910095,"name":"vapor","full_name":"qutheory/vapor","owner":{"login":"qutheory","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/qutheory","html_url":"https://github.com/qutheory","followers_url":"https://api.github.com/users/qutheory/followers","following_url":"https://api.github.com/users/qutheory/following{/other_user}","gists_url":"https://api.github.com/users/qutheory/gists{/gist_id}","starred_url":"https://api.github.com/users/qutheory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qutheory/subscriptions","organizations_url":"https://api.github.com/users/qutheory/orgs","repos_url":"https://api.github.com/users/qutheory/repos","events_url":"https://api.github.com/users/qutheory/events{/privacy}","received_events_url":"https://api.github.com/users/qutheory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/qutheory/vapor","description":"A web framework and server for Swift that works on OS X and Ubuntu.","fork":false,"url":"https://api.github.com/repos/qutheory/vapor","forks_url":"https://api.github.com/repos/qutheory/vapor/forks","keys_url":"https://api.github.com/repos/qutheory/vapor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qutheory/vapor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qutheory/vapor/teams","hooks_url":"https://api.github.com/repos/qutheory/vapor/hooks","issue_events_url":"https://api.github.com/repos/qutheory/vapor/issues/events{/number}","events_url":"https://api.github.com/repos/qutheory/vapor/events","assignees_url":"https://api.github.com/repos/qutheory/vapor/assignees{/user}","branches_url":"https://api.github.com/repos/qutheory/vapor/branches{/branch}","tags_url":"https://api.github.com/repos/qutheory/vapor/tags","blobs_url":"https://api.github.com/repos/qutheory/vapor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qutheory/vapor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qutheory/vapor/git/refs{/sha}","trees_url":"https://api.github.com/repos/qutheory/vapor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qutheory/vapor/statuses/{sha}","languages_url":"https://api.github.com/repos/qutheory/vapor/languages","stargazers_url":"https://api.github.com/repos/qutheory/vapor/stargazers","contributors_url":"https://api.github.com/repos/qutheory/vapor/contributors","subscribers_url":"https://api.github.com/repos/qutheory/vapor/subscribers","subscription_url":"https://api.github.com/repos/qutheory/vapor/subscription","commits_url":"https://api.github.com/repos/qutheory/vapor/commits{/sha}","git_commits_url":"https://api.github.com/repos/qutheory/vapor/git/commits{/sha}","comments_url":"https://api.github.com/repos/qutheory/vapor/comments{/number}","issue_comment_url":"https://api.github.com/repos/qutheory/vapor/issues/comments{/number}","contents_url":"https://api.github.com/repos/qutheory/vapor/contents/{+path}","compare_url":"https://api.github.com/repos/qutheory/vapor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qutheory/vapor/merges","archive_url":"https://api.github.com/repos/qutheory/vapor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qutheory/vapor/downloads","issues_url":"https://api.github.com/repos/qutheory/vapor/issues{/number}","pulls_url":"https://api.github.com/repos/qutheory/vapor/pulls{/number}","milestones_url":"https://api.github.com/repos/qutheory/vapor/milestones{/number}","notifications_url":"https://api.github.com/repos/qutheory/vapor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qutheory/vapor/labels{/name}","releases_url":"https://api.github.com/repos/qutheory/vapor/releases{/id}","deployments_url":"https://api.github.com/repos/qutheory/vapor/deployments","created_at":"2016-01-18T22:37:52Z","updated_at":"2016-06-10T04:08:52Z","pushed_at":"2016-06-10T04:14:48Z","git_url":"git://github.com/qutheory/vapor.git","ssh_url":"git@github.com:qutheory/vapor.git","clone_url":"https://github.com/qutheory/vapor.git","svn_url":"https://github.com/qutheory/vapor","homepage":"qutheory.io","size":7360,"stargazers_count":4191,"watchers_count":4191,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":223,"mirror_url":null,"open_issues_count":42,"forks":223,"open_issues":42,"watchers":4191,"default_branch":"master"}},"base":{"label":"qutheory:master","ref":"master","sha":"f03f901389cc8ccb83429338c89cabd6cc282d2a","user":{"login":"qutheory","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/qutheory","html_url":"https://github.com/qutheory","followers_url":"https://api.github.com/users/qutheory/followers","following_url":"https://api.github.com/users/qutheory/following{/other_user}","gists_url":"https://api.github.com/users/qutheory/gists{/gist_id}","starred_url":"https://api.github.com/users/qutheory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qutheory/subscriptions","organizations_url":"https://api.github.com/users/qutheory/orgs","repos_url":"https://api.github.com/users/qutheory/repos","events_url":"https://api.github.com/users/qutheory/events{/privacy}","received_events_url":"https://api.github.com/users/qutheory/received_events","type":"Organization","site_admin":false},"repo":{"id":49910095,"name":"vapor","full_name":"qutheory/vapor","owner":{"login":"qutheory","id":17364220,"avatar_url":"https://avatars.githubusercontent.com/u/17364220?v=3","gravatar_id":"","url":"https://api.github.com/users/qutheory","html_url":"https://github.com/qutheory","followers_url":"https://api.github.com/users/qutheory/followers","following_url":"https://api.github.com/users/qutheory/following{/other_user}","gists_url":"https://api.github.com/users/qutheory/gists{/gist_id}","starred_url":"https://api.github.com/users/qutheory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qutheory/subscriptions","organizations_url":"https://api.github.com/users/qutheory/orgs","repos_url":"https://api.github.com/users/qutheory/repos","events_url":"https://api.github.com/users/qutheory/events{/privacy}","received_events_url":"https://api.github.com/users/qutheory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/qutheory/vapor","description":"A web framework and server for Swift that works on OS X and Ubuntu.","fork":false,"url":"https://api.github.com/repos/qutheory/vapor","forks_url":"https://api.github.com/repos/qutheory/vapor/forks","keys_url":"https://api.github.com/repos/qutheory/vapor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/qutheory/vapor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/qutheory/vapor/teams","hooks_url":"https://api.github.com/repos/qutheory/vapor/hooks","issue_events_url":"https://api.github.com/repos/qutheory/vapor/issues/events{/number}","events_url":"https://api.github.com/repos/qutheory/vapor/events","assignees_url":"https://api.github.com/repos/qutheory/vapor/assignees{/user}","branches_url":"https://api.github.com/repos/qutheory/vapor/branches{/branch}","tags_url":"https://api.github.com/repos/qutheory/vapor/tags","blobs_url":"https://api.github.com/repos/qutheory/vapor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/qutheory/vapor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/qutheory/vapor/git/refs{/sha}","trees_url":"https://api.github.com/repos/qutheory/vapor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/qutheory/vapor/statuses/{sha}","languages_url":"https://api.github.com/repos/qutheory/vapor/languages","stargazers_url":"https://api.github.com/repos/qutheory/vapor/stargazers","contributors_url":"https://api.github.com/repos/qutheory/vapor/contributors","subscribers_url":"https://api.github.com/repos/qutheory/vapor/subscribers","subscription_url":"https://api.github.com/repos/qutheory/vapor/subscription","commits_url":"https://api.github.com/repos/qutheory/vapor/commits{/sha}","git_commits_url":"https://api.github.com/repos/qutheory/vapor/git/commits{/sha}","comments_url":"https://api.github.com/repos/qutheory/vapor/comments{/number}","issue_comment_url":"https://api.github.com/repos/qutheory/vapor/issues/comments{/number}","contents_url":"https://api.github.com/repos/qutheory/vapor/contents/{+path}","compare_url":"https://api.github.com/repos/qutheory/vapor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/qutheory/vapor/merges","archive_url":"https://api.github.com/repos/qutheory/vapor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/qutheory/vapor/downloads","issues_url":"https://api.github.com/repos/qutheory/vapor/issues{/number}","pulls_url":"https://api.github.com/repos/qutheory/vapor/pulls{/number}","milestones_url":"https://api.github.com/repos/qutheory/vapor/milestones{/number}","notifications_url":"https://api.github.com/repos/qutheory/vapor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/qutheory/vapor/labels{/name}","releases_url":"https://api.github.com/repos/qutheory/vapor/releases{/id}","deployments_url":"https://api.github.com/repos/qutheory/vapor/deployments","created_at":"2016-01-18T22:37:52Z","updated_at":"2016-06-10T04:08:52Z","pushed_at":"2016-06-10T04:14:48Z","git_url":"git://github.com/qutheory/vapor.git","ssh_url":"git@github.com:qutheory/vapor.git","clone_url":"https://github.com/qutheory/vapor.git","svn_url":"https://github.com/qutheory/vapor","homepage":"qutheory.io","size":7360,"stargazers_count":4191,"watchers_count":4191,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":223,"mirror_url":null,"open_issues_count":42,"forks":223,"open_issues":42,"watchers":4191,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/qutheory/vapor/pulls/374"},"html":{"href":"https://github.com/qutheory/vapor/pull/374"},"issue":{"href":"https://api.github.com/repos/qutheory/vapor/issues/374"},"comments":{"href":"https://api.github.com/repos/qutheory/vapor/issues/374/comments"},"review_comments":{"href":"https://api.github.com/repos/qutheory/vapor/pulls/374/comments"},"review_comment":{"href":"https://api.github.com/repos/qutheory/vapor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/qutheory/vapor/pulls/374/commits"},"statuses":{"href":"https://api.github.com/repos/qutheory/vapor/statuses/f5b6fbab353d38d7edfab0d365956b64ce90e1b1"}}}}
{"actor":{"display_login":"tannernelson"}}