{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/41931519","id":41931519,"diff_hunk":"@@ -420,63 +350,53 @@ var BlobView = (function() {\n     },\n \n     // Read bytes up to and including a null terminator, but never\n-    // more than size bytes.  And return as a Latin1 string\n-    readNullTerminatedLatin1Text: function(size) {\n-      var s = '';\n-      for (var i = 0; i < size; i++) {\n-        var charcode = this.view.getUint8(this.index + i);\n-        if (charcode === 0) {\n-          i++;\n-          break;\n-        }\n-        s += String.fromCharCode(charcode);\n+    // more than size bytes.  And return as an ASCII string\n+    readNullTerminatedLatin1Text: function(size, advance_by_size = false) {\n+      var bytes = new Uint8Array(this.buffer, this.viewOffset + this.index,\n+                                 size);\n+\n+      var nil = bytes.indexOf(0);\n+      if (nil !== -1) {\n+        bytes = bytes.subarray(0, nil);\n       }\n-      this.index += i;\n+\n+      var s = getDecoder('latin1').decode(bytes);\n+      this.index += (nil !== -1 && !advance_by_size) ? nil + 1 : size;\n       return s;\n     },\n \n     // Read bytes up to and including a null terminator, but never\n     // more than size bytes.  And return as a UTF8 string\n-    readNullTerminatedUTF8Text: function(size) {\n-      for (var len = 0; len < size; len++) {\n-        if (this.view.getUint8(this.index + len) === 0) {\n-          break;\n-        }\n-      }\n-      var s = this.readUTF8Text(len);\n-      if (len < size) {    // skip the null terminator if we found one\n-        this.advance(1);\n+    readNullTerminatedUTF8Text: function(size, advance_by_size = false) {\n+      var bytes = new Uint8Array(this.buffer, this.viewOffset + this.index,\n+                                 size);\n+\n+      var nil = bytes.indexOf(0);\n+      if (nil !== -1) {\n+        bytes = bytes.subarray(0, nil);\n       }\n+\n+      var s = getDecoder('utf-8').decode(bytes);\n+      this.index += (nil !== -1 && !advance_by_size) ? nil + 1 : size;","path":"shared/js/blobview.js","position":256,"original_position":256,"commit_id":"1703c57d190bb294c724d2bc072e1fd5665f0b42","original_commit_id":"1703c57d190bb294c724d2bc072e1fd5665f0b42","user":{"login":"davidflanagan","id":516914,"avatar_url":"https://avatars.githubusercontent.com/u/516914?v=3","gravatar_id":"","url":"https://api.github.com/users/davidflanagan","html_url":"https://github.com/davidflanagan","followers_url":"https://api.github.com/users/davidflanagan/followers","following_url":"https://api.github.com/users/davidflanagan/following{/other_user}","gists_url":"https://api.github.com/users/davidflanagan/gists{/gist_id}","starred_url":"https://api.github.com/users/davidflanagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidflanagan/subscriptions","organizations_url":"https://api.github.com/users/davidflanagan/orgs","repos_url":"https://api.github.com/users/davidflanagan/repos","events_url":"https://api.github.com/users/davidflanagan/events{/privacy}","received_events_url":"https://api.github.com/users/davidflanagan/received_events","type":"User","site_admin":false},"body":"Same comments here about if/else and documenting the new argument.","created_at":"2015-10-13T21:56:43Z","updated_at":"2015-10-13T21:56:43Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/32256#discussion_r41931519","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/41931519"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/32256#discussion_r41931519"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256","id":46848551,"html_url":"https://github.com/mozilla-b2g/gaia/pull/32256","diff_url":"https://github.com/mozilla-b2g/gaia/pull/32256.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/32256.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32256","number":32256,"state":"open","locked":false,"title":"Bug 910576 - Use TextDecoder in BlobView","user":{"login":"jimporter","id":826865,"avatar_url":"https://avatars.githubusercontent.com/u/826865?v=3","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-05T23:52:15Z","updated_at":"2015-10-13T21:56:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e7bbbaadfaf6ace20cd80e3ec9f8faf97b9c90c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32256/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/1703c57d190bb294c724d2bc072e1fd5665f0b42","head":{"label":"jimporter:blobview-textdecoder","ref":"blobview-textdecoder","sha":"1703c57d190bb294c724d2bc072e1fd5665f0b42","user":{"login":"jimporter","id":826865,"avatar_url":"https://avatars.githubusercontent.com/u/826865?v=3","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"repo":{"id":7586186,"name":"gaia","full_name":"jimporter/gaia","owner":{"login":"jimporter","id":826865,"avatar_url":"https://avatars.githubusercontent.com/u/826865?v=3","gravatar_id":"","url":"https://api.github.com/users/jimporter","html_url":"https://github.com/jimporter","followers_url":"https://api.github.com/users/jimporter/followers","following_url":"https://api.github.com/users/jimporter/following{/other_user}","gists_url":"https://api.github.com/users/jimporter/gists{/gist_id}","starred_url":"https://api.github.com/users/jimporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimporter/subscriptions","organizations_url":"https://api.github.com/users/jimporter/orgs","repos_url":"https://api.github.com/users/jimporter/repos","events_url":"https://api.github.com/users/jimporter/events{/privacy}","received_events_url":"https://api.github.com/users/jimporter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jimporter/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project","fork":true,"url":"https://api.github.com/repos/jimporter/gaia","forks_url":"https://api.github.com/repos/jimporter/gaia/forks","keys_url":"https://api.github.com/repos/jimporter/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jimporter/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jimporter/gaia/teams","hooks_url":"https://api.github.com/repos/jimporter/gaia/hooks","issue_events_url":"https://api.github.com/repos/jimporter/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/jimporter/gaia/events","assignees_url":"https://api.github.com/repos/jimporter/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/jimporter/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/jimporter/gaia/tags","blobs_url":"https://api.github.com/repos/jimporter/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jimporter/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jimporter/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/jimporter/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jimporter/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/jimporter/gaia/languages","stargazers_url":"https://api.github.com/repos/jimporter/gaia/stargazers","contributors_url":"https://api.github.com/repos/jimporter/gaia/contributors","subscribers_url":"https://api.github.com/repos/jimporter/gaia/subscribers","subscription_url":"https://api.github.com/repos/jimporter/gaia/subscription","commits_url":"https://api.github.com/repos/jimporter/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/jimporter/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/jimporter/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/jimporter/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/jimporter/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/jimporter/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jimporter/gaia/merges","archive_url":"https://api.github.com/repos/jimporter/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jimporter/gaia/downloads","issues_url":"https://api.github.com/repos/jimporter/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/jimporter/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/jimporter/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/jimporter/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jimporter/gaia/labels{/name}","releases_url":"https://api.github.com/repos/jimporter/gaia/releases{/id}","created_at":"2013-01-13T08:57:30Z","updated_at":"2015-04-30T21:44:46Z","pushed_at":"2015-10-13T00:19:40Z","git_url":"git://github.com/jimporter/gaia.git","ssh_url":"git@github.com:jimporter/gaia.git","clone_url":"https://github.com/jimporter/gaia.git","svn_url":"https://github.com/jimporter/gaia","homepage":"https://wiki.mozilla.org/B2G","size":921686,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"mozilla-b2g:master","ref":"master","sha":"3337e2b5a9f5acc8eb7c771ca165ec8b2d435264","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","created_at":"2011-09-03T01:38:46Z","updated_at":"2015-10-13T18:44:30Z","pushed_at":"2015-10-13T21:44:33Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1651893,"stargazers_count":1991,"watchers_count":1991,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2468,"mirror_url":null,"open_issues_count":1238,"forks":2468,"open_issues":1238,"watchers":1991,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/32256"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32256"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/32256/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/32256/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/1703c57d190bb294c724d2bc072e1fd5665f0b42"}}}}