{"action":"created","issue":{"url":"https://api.github.com/repos/iojs/io.js/issues/1202","labels_url":"https://api.github.com/repos/iojs/io.js/issues/1202/labels{/name}","comments_url":"https://api.github.com/repos/iojs/io.js/issues/1202/comments","events_url":"https://api.github.com/repos/iojs/io.js/issues/1202/events","html_url":"https://github.com/iojs/io.js/pull/1202","id":62927791,"number":1202,"title":"buffer: add buf.mask for ws","user":{"login":"chrisdickinson","id":37303,"avatar_url":"https://avatars.githubusercontent.com/u/37303?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisdickinson","html_url":"https://github.com/chrisdickinson","followers_url":"https://api.github.com/users/chrisdickinson/followers","following_url":"https://api.github.com/users/chrisdickinson/following{/other_user}","gists_url":"https://api.github.com/users/chrisdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdickinson/subscriptions","organizations_url":"https://api.github.com/users/chrisdickinson/orgs","repos_url":"https://api.github.com/users/chrisdickinson/repos","events_url":"https://api.github.com/users/chrisdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdickinson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/iojs/io.js/labels/buffer","name":"buffer","color":"f7c6c7"},{"url":"https://api.github.com/repos/iojs/io.js/labels/semver-minor","name":"semver-minor","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-19T09:27:56Z","updated_at":"2015-03-19T14:24:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/iojs/io.js/pulls/1202","html_url":"https://github.com/iojs/io.js/pull/1202","diff_url":"https://github.com/iojs/io.js/pull/1202.diff","patch_url":"https://github.com/iojs/io.js/pull/1202.patch"},"body":"This patch adds `buf.mask(maskValue, targetBuffer, targetOffset, sourceStart, sourceEnd)`, needed by the ws package for [masking](https://github.com/websockets/ws/blob/ac283f0368375e674fa370cd4b64cef42add2968/lib/Sender.js#L194) and unmasking websocket frames. The original implementation is [here](https://github.com/websockets/bufferutil/blob/3bbb6f23193fae7683b61e2cae1f85ede5fb4469/src/bufferutil.cc#L85). It is implemented as a partially unrolled loop, operating on 32-bit values and dealing with the 0-3 byte remainder at the end – I'm not sure if we want to retain this optimization, since the `sourceStart` and `targetOffset` params make it possible to trigger non-8-byte-aligned copies.\r\n\r\nI didn't implement [`Unmask`](https://github.com/websockets/bufferutil/blob/3bbb6f23193fae7683b61e2cae1f85ede5fb4469/src/bufferutil.cc#L64): it should be equivalent to `buf.mask(mask, buf)`. [`Merge`](https://github.com/websockets/bufferutil/blob/3bbb6f23193fae7683b61e2cae1f85ede5fb4469/src/bufferutil.cc#L46) is also omitted. I'll have another PR up for [`Utf8Validate`](https://github.com/websockets/utf-8-validate/blob/master/src/validation.cc) tomorrow.\r\n\r\nR=@trevnorris, @piscisaureus "},"comment":{"url":"https://api.github.com/repos/iojs/io.js/issues/comments/83603525","html_url":"https://github.com/iojs/io.js/pull/1202#issuecomment-83603525","issue_url":"https://api.github.com/repos/iojs/io.js/issues/1202","id":83603525,"user":{"login":"Fishrock123","id":1093990,"avatar_url":"https://avatars.githubusercontent.com/u/1093990?v=3","gravatar_id":"","url":"https://api.github.com/users/Fishrock123","html_url":"https://github.com/Fishrock123","followers_url":"https://api.github.com/users/Fishrock123/followers","following_url":"https://api.github.com/users/Fishrock123/following{/other_user}","gists_url":"https://api.github.com/users/Fishrock123/gists{/gist_id}","starred_url":"https://api.github.com/users/Fishrock123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fishrock123/subscriptions","organizations_url":"https://api.github.com/users/Fishrock123/orgs","repos_url":"https://api.github.com/users/Fishrock123/repos","events_url":"https://api.github.com/users/Fishrock123/events{/privacy}","received_events_url":"https://api.github.com/users/Fishrock123/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T14:24:13Z","updated_at":"2015-03-19T14:24:13Z","body":"Not a code review but +1 to these additions. :D"}}