{"action":"created","comment":{"url":"https://api.github.com/repos/mongodb/js-bson/pulls/comments/35021980","id":35021980,"diff_hunk":"@@ -1282,8 +1284,13 @@ BSON.deserialize = function(buffer, options, isArray) {\n           if(subType == Binary.SUBTYPE_BYTE_ARRAY) {\n             binarySize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24;\n           }\n-          // Slice the data\n-          object[name] = new Binary(buffer.slice(index, index + binarySize), subType);\n+          if(nativeBuffers) {\n+            // Slice the data and create a native Buffer object\n+            object[name] = new Buffer(buffer.slice(index, index + binarySize));","path":"lib/bson/bson.js","position":24,"original_position":24,"commit_id":"bf4dc3c32a97f42f929d2269bac4cccc4427a009","original_commit_id":"bf4dc3c32a97f42f929d2269bac4cccc4427a009","user":{"login":"tellnes","id":613729,"avatar_url":"https://avatars.githubusercontent.com/u/613729?v=3","gravatar_id":"","url":"https://api.github.com/users/tellnes","html_url":"https://github.com/tellnes","followers_url":"https://api.github.com/users/tellnes/followers","following_url":"https://api.github.com/users/tellnes/following{/other_user}","gists_url":"https://api.github.com/users/tellnes/gists{/gist_id}","starred_url":"https://api.github.com/users/tellnes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tellnes/subscriptions","organizations_url":"https://api.github.com/users/tellnes/orgs","repos_url":"https://api.github.com/users/tellnes/repos","events_url":"https://api.github.com/users/tellnes/events{/privacy}","received_events_url":"https://api.github.com/users/tellnes/received_events","type":"User","site_admin":false},"body":"`buffer.slice()` returns a buffer, why not just use that? Now you are doing a memory copy. https://github.com/nodejs/io.js/blob/master/lib/buffer.js#L96-L100","created_at":"2015-07-20T17:43:27Z","updated_at":"2015-07-20T17:43:27Z","html_url":"https://github.com/mongodb/js-bson/pull/116#discussion_r35021980","pull_request_url":"https://api.github.com/repos/mongodb/js-bson/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/mongodb/js-bson/pulls/comments/35021980"},"html":{"href":"https://github.com/mongodb/js-bson/pull/116#discussion_r35021980"},"pull_request":{"href":"https://api.github.com/repos/mongodb/js-bson/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/mongodb/js-bson/pulls/116","id":30526509,"html_url":"https://github.com/mongodb/js-bson/pull/116","diff_url":"https://github.com/mongodb/js-bson/pull/116.diff","patch_url":"https://github.com/mongodb/js-bson/pull/116.patch","issue_url":"https://api.github.com/repos/mongodb/js-bson/issues/116","number":116,"state":"open","locked":false,"title":"add option for deserializing binary into Buffer object","user":{"login":"msmiley","id":138650,"avatar_url":"https://avatars.githubusercontent.com/u/138650?v=3","gravatar_id":"","url":"https://api.github.com/users/msmiley","html_url":"https://github.com/msmiley","followers_url":"https://api.github.com/users/msmiley/followers","following_url":"https://api.github.com/users/msmiley/following{/other_user}","gists_url":"https://api.github.com/users/msmiley/gists{/gist_id}","starred_url":"https://api.github.com/users/msmiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msmiley/subscriptions","organizations_url":"https://api.github.com/users/msmiley/orgs","repos_url":"https://api.github.com/users/msmiley/repos","events_url":"https://api.github.com/users/msmiley/events{/privacy}","received_events_url":"https://api.github.com/users/msmiley/received_events","type":"User","site_admin":false},"body":"**nativeBuffers** {Boolean, default:false}","created_at":"2015-03-05T03:02:33Z","updated_at":"2015-07-20T17:43:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1d41a76f6e2895470a5113fafe20c9c15d754082","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/js-bson/pulls/116/commits","review_comments_url":"https://api.github.com/repos/mongodb/js-bson/pulls/116/comments","review_comment_url":"https://api.github.com/repos/mongodb/js-bson/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/js-bson/issues/116/comments","statuses_url":"https://api.github.com/repos/mongodb/js-bson/statuses/bf4dc3c32a97f42f929d2269bac4cccc4427a009","head":{"label":"msmiley:master","ref":"master","sha":"bf4dc3c32a97f42f929d2269bac4cccc4427a009","user":{"login":"msmiley","id":138650,"avatar_url":"https://avatars.githubusercontent.com/u/138650?v=3","gravatar_id":"","url":"https://api.github.com/users/msmiley","html_url":"https://github.com/msmiley","followers_url":"https://api.github.com/users/msmiley/followers","following_url":"https://api.github.com/users/msmiley/following{/other_user}","gists_url":"https://api.github.com/users/msmiley/gists{/gist_id}","starred_url":"https://api.github.com/users/msmiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msmiley/subscriptions","organizations_url":"https://api.github.com/users/msmiley/orgs","repos_url":"https://api.github.com/users/msmiley/repos","events_url":"https://api.github.com/users/msmiley/events{/privacy}","received_events_url":"https://api.github.com/users/msmiley/received_events","type":"User","site_admin":false},"repo":{"id":31681382,"name":"js-bson","full_name":"msmiley/js-bson","owner":{"login":"msmiley","id":138650,"avatar_url":"https://avatars.githubusercontent.com/u/138650?v=3","gravatar_id":"","url":"https://api.github.com/users/msmiley","html_url":"https://github.com/msmiley","followers_url":"https://api.github.com/users/msmiley/followers","following_url":"https://api.github.com/users/msmiley/following{/other_user}","gists_url":"https://api.github.com/users/msmiley/gists{/gist_id}","starred_url":"https://api.github.com/users/msmiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msmiley/subscriptions","organizations_url":"https://api.github.com/users/msmiley/orgs","repos_url":"https://api.github.com/users/msmiley/repos","events_url":"https://api.github.com/users/msmiley/events{/privacy}","received_events_url":"https://api.github.com/users/msmiley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/msmiley/js-bson","description":"BSON Parser for node and browser","fork":true,"url":"https://api.github.com/repos/msmiley/js-bson","forks_url":"https://api.github.com/repos/msmiley/js-bson/forks","keys_url":"https://api.github.com/repos/msmiley/js-bson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/msmiley/js-bson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/msmiley/js-bson/teams","hooks_url":"https://api.github.com/repos/msmiley/js-bson/hooks","issue_events_url":"https://api.github.com/repos/msmiley/js-bson/issues/events{/number}","events_url":"https://api.github.com/repos/msmiley/js-bson/events","assignees_url":"https://api.github.com/repos/msmiley/js-bson/assignees{/user}","branches_url":"https://api.github.com/repos/msmiley/js-bson/branches{/branch}","tags_url":"https://api.github.com/repos/msmiley/js-bson/tags","blobs_url":"https://api.github.com/repos/msmiley/js-bson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/msmiley/js-bson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/msmiley/js-bson/git/refs{/sha}","trees_url":"https://api.github.com/repos/msmiley/js-bson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/msmiley/js-bson/statuses/{sha}","languages_url":"https://api.github.com/repos/msmiley/js-bson/languages","stargazers_url":"https://api.github.com/repos/msmiley/js-bson/stargazers","contributors_url":"https://api.github.com/repos/msmiley/js-bson/contributors","subscribers_url":"https://api.github.com/repos/msmiley/js-bson/subscribers","subscription_url":"https://api.github.com/repos/msmiley/js-bson/subscription","commits_url":"https://api.github.com/repos/msmiley/js-bson/commits{/sha}","git_commits_url":"https://api.github.com/repos/msmiley/js-bson/git/commits{/sha}","comments_url":"https://api.github.com/repos/msmiley/js-bson/comments{/number}","issue_comment_url":"https://api.github.com/repos/msmiley/js-bson/issues/comments{/number}","contents_url":"https://api.github.com/repos/msmiley/js-bson/contents/{+path}","compare_url":"https://api.github.com/repos/msmiley/js-bson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/msmiley/js-bson/merges","archive_url":"https://api.github.com/repos/msmiley/js-bson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/msmiley/js-bson/downloads","issues_url":"https://api.github.com/repos/msmiley/js-bson/issues{/number}","pulls_url":"https://api.github.com/repos/msmiley/js-bson/pulls{/number}","milestones_url":"https://api.github.com/repos/msmiley/js-bson/milestones{/number}","notifications_url":"https://api.github.com/repos/msmiley/js-bson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/msmiley/js-bson/labels{/name}","releases_url":"https://api.github.com/repos/msmiley/js-bson/releases{/id}","created_at":"2015-03-04T21:41:49Z","updated_at":"2015-03-05T03:00:18Z","pushed_at":"2015-03-05T03:00:17Z","git_url":"git://github.com/msmiley/js-bson.git","ssh_url":"git@github.com:msmiley/js-bson.git","clone_url":"https://github.com/msmiley/js-bson.git","svn_url":"https://github.com/msmiley/js-bson","homepage":"","size":800,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"master"}},"base":{"label":"mongodb:master","ref":"master","sha":"d8048869418ab9f88fd6b4f27f3200ee10eb6a40","user":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":3658431,"name":"js-bson","full_name":"mongodb/js-bson","owner":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb/js-bson","description":"BSON Parser for node and browser","fork":false,"url":"https://api.github.com/repos/mongodb/js-bson","forks_url":"https://api.github.com/repos/mongodb/js-bson/forks","keys_url":"https://api.github.com/repos/mongodb/js-bson/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/js-bson/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/js-bson/teams","hooks_url":"https://api.github.com/repos/mongodb/js-bson/hooks","issue_events_url":"https://api.github.com/repos/mongodb/js-bson/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/js-bson/events","assignees_url":"https://api.github.com/repos/mongodb/js-bson/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/js-bson/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/js-bson/tags","blobs_url":"https://api.github.com/repos/mongodb/js-bson/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/js-bson/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/js-bson/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/js-bson/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/js-bson/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/js-bson/languages","stargazers_url":"https://api.github.com/repos/mongodb/js-bson/stargazers","contributors_url":"https://api.github.com/repos/mongodb/js-bson/contributors","subscribers_url":"https://api.github.com/repos/mongodb/js-bson/subscribers","subscription_url":"https://api.github.com/repos/mongodb/js-bson/subscription","commits_url":"https://api.github.com/repos/mongodb/js-bson/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/js-bson/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/js-bson/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/js-bson/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/js-bson/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/js-bson/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/js-bson/merges","archive_url":"https://api.github.com/repos/mongodb/js-bson/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/js-bson/downloads","issues_url":"https://api.github.com/repos/mongodb/js-bson/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/js-bson/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/js-bson/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/js-bson/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/js-bson/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/js-bson/releases{/id}","created_at":"2012-03-08T09:15:24Z","updated_at":"2015-07-08T02:50:52Z","pushed_at":"2015-07-14T09:13:21Z","git_url":"git://github.com/mongodb/js-bson.git","ssh_url":"git@github.com:mongodb/js-bson.git","clone_url":"https://github.com/mongodb/js-bson.git","svn_url":"https://github.com/mongodb/js-bson","homepage":"","size":1683,"stargazers_count":226,"watchers_count":226,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":80,"mirror_url":null,"open_issues_count":7,"forks":80,"open_issues":7,"watchers":226,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/js-bson/pulls/116"},"html":{"href":"https://github.com/mongodb/js-bson/pull/116"},"issue":{"href":"https://api.github.com/repos/mongodb/js-bson/issues/116"},"comments":{"href":"https://api.github.com/repos/mongodb/js-bson/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/js-bson/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/js-bson/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/js-bson/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/js-bson/statuses/bf4dc3c32a97f42f929d2269bac4cccc4427a009"}}}}